Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular track by and orderBy

Starting to use Angular and playing with a demo. In the model, the event item includes a start time called starts_at and a title.

I had a tag using ng-repeat="event in events track by $index" and tried adding in "|orderBy: event.starts_at" It didn't seem to influence the sorting in any way until I removed the track section.

Does track disables any option for sorting in angular ?

like image 302
ggivati Avatar asked Jan 03 '15 11:01

ggivati


1 Answers

According to docs: https://docs.angularjs.org/api/ng/directive/ngRepeat filter expressions (and I suspect, order) come before tracking expressions.

Example:

item in items | filter:searchText track by item.id
like image 63
Jevgenij Evll Avatar answered Nov 15 '22 10:11

Jevgenij Evll