Automatic Serial Nos in ng-Repeat (Angular)

前端 未结 2 803
心在旅途
心在旅途 2020-12-07 04:43

I am using ng-Repeat to fill the table with data in Controller (or from Services). However, I need to fullfill Serial Nos in first column automatically. Currently I am getti

2条回答
  •  再見小時候
    2020-12-07 05:36

    There are two ways to get an index for the given array in ng-repeat

    Using $index

    {{$index}}
    

    Using a counter

    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}}
    

提交回复
热议问题