2

I can think of a few hacky ways, but for example below in my doSomething method, how can i determine the rowIndex?

        <tr ng-repeat="a in mydata">
            <td><b>{{doSomething(mydata.name)}}</b></td>
            <td>{{age}}</td>
            <td>hello</td>
        </tr>

2 Answers 2

7

ng-repeat provides properties $first, $index, $middle, and $last. Since in the title question you asked about the first row, you could pass $first as a boolean:

<tr ng-repeat="a in mydata">
    <td><b>{{doSomething($first)}}</b></td>
    <td>{{a.age}}</td>
    <td>hello</td>
</tr>
Sign up to request clarification or add additional context in comments.

Comments

2

AngularJS automatically includes the magic $index in an ng-repeat. So you can get the row number like so:

<tr ng-repeat="a in mydata">
  <td><b>{{doSomething($index)}}</b></td>
  <td>{{a.name}}</td>
  <td>{{a.age}}</td>
</tr>

1 Comment

I have been using angular for 1 day and i am LOVING IT! Thanks for the quick easy answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.