Reputation: 199
<tr ng-repeat="car in cars | filter:search:strict | orderBy: 'Type'">
<td>{{car.Type}}</td>
<td>{{car.Name}}</td>
<td>{{car.Year}}</td>
</tr>
Can I get a car's index
: a number which represents a place in cars array?
Currently, it is not in right order, because of orderBy
filter.
Upvotes: 1
Views: 792
Reputation: 18513
You could just call indexOf() with your car object to get its original index
<tr ng-repeat="car in cars | filter:search:strict | orderBy: 'Type'" ng-click="someFunc(cars.indexOf(car))">
<td>{{car.Type}}</td>
<td>{{car.Name}}</td>
<td>{{car.Year}}</td>
</tr>
Upvotes: 0
Reputation: 9454
Do the sorting in a controller. Then place the sorted items into a cars array. Then do
<tr ng-repeat="car in cars track by $index">
<td>{{$index}}</td>
<td>{{car.Type}}</td>
<td>{{car.Name}}</td>
<td>{{car.Year}}</td>
</tr>
Upvotes: 1