Angular.js: Using order by with List that is track by $index does not perform sorting

Created on 25 Jul 2014  ·  3Comments  ·  Source: angular/angular.js

Hello there,

I am using performing sorting in our angularJS application using Orderby. But when triing to sort the list that is track by $index it doesn't work.

Tried doing the same in the example for orderBy (https://docs.angularjs.org/api/ng/filter/orderBy) on angularJS official website through Plunker and it seems to be issue there too

http://plnkr.co/edit/IYSitUaZpLK8YCHnJvqY?p=preview

Most helpful comment

Documentation for ngRepeat mentions that:

Filters should be applied to the expression, before specifying a tracking expression.

So try this instead:

ng-repeat="friend in friends | orderBy:predicate:reverse track by $index"

All 3 comments

Documentation for ngRepeat mentions that:

Filters should be applied to the expression, before specifying a tracking expression.

So try this instead:

ng-repeat="friend in friends | orderBy:predicate:reverse track by $index"

Thanks got the issue resolved :+1:

thanks, it's _work

Was this page helpful?
0 / 5 - 0 ratings