In my code, I have an ng-repeat setup like this:
ng-repeat="article in main[main.mode].primary | orderBy: main[main.mode].primary.filter.order
track by article.url"
The main[main.mode].primary
array contains the data and the .filter.order
string is used for ordering.
I came across a helpful blog post that explained how ngRepeat adds a $$hashKey property to each item behind the scenes to keep track of it. This causes issues when trying to refresh or regenerate the list with new items because they don't have the same $$hashKey property as the original items.
My application experiences a delay of over a second when regenerating the list, which led me to investigate using the track by feature. Despite following the correct syntax for ordering and tracking an array according to various resources I consulted, the track by functionality doesn't seem to be working as expected. The AngularJS docs mention the following pattern for using track by with filtering:
item in items | filter:searchText track by item.id is a pattern that might be used to apply a filter to items in conjunction with a tracking expression.
I'm puzzled as to why the track by feature isn't working as intended, especially since I am using Angular version 1.3.11.
Edit: Even removing the orderBy argument didn't solve the issue:
ng-repeat="article in main[main.mode].primary track by article.url"