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
Use $index
:
<td>{{$index + 1}}</td>
<td>{{x.name}}</td>
There are two ways to get an index for the given array in ng-repeat
<th ng-repeat="n in [].constructor(3 + 1) track by $index">{{$index}}</th>
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.
<tr ng-repeat="(row, y) in getNumber(h.seats.length, 3) track by $index">
<td>{{row+1}}</td>