0

I'm using AngularJS to create a table of data. Since Angular allows you to filter and order the data in the controller, is there a way to specify an incremental value?

For example:

Rank | UserName | Score | Last Played

Here The ranking is going to be ordered by the highest score.

What would be the angular expression to set the Rank accordingly?

1 Answer 1

4

From: Increment A Variable In AngularJS Template

{{$index + 1}}

$index contains the current 0-based index for ng-repeat

So I have:

<tbody>
 <tr ng-repeat="user in users">
  <td>{{$index + 1}}</td>
  <td>{{user.UserName}}</td>
  <td>{{user.Score}}</td>
  <td>{{user.LastPlayed}}</td>
 </tr>
</tbody>
Sign up to request clarification or add additional context in comments.

Comments

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.