I am using AngularJS and its ng-repeat
directive to display a sequence of questions. I need to number each question starting with 1
. How do I display a
There are two ways to get an index for the given array in ng-repeat
{{$index}}
This method is useful when you have nested ng-repeat and you need counters for both loops...the following example uses counter row. Although track by $index is required, it is not used for the logic.
{{row+1}}
In both cases counter starts with 0 and you can offset using +1 if you like
- 热议问题