1
<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.

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

Comments

0

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>

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.