My HTML code includes the following element:
<button ng-click="console.log(key)" ng-repeat="(key, value) in getLocalStorageKeys() track by $index">
In my JavaScript file, I have the following function:
$scope.getLocalStorageKeys = function(){
return localStorageService.get('accountKeys');
};
You can view the Local Storage value here:
Despite my efforts, I continue to encounter the following error message:
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached.
Aborting!
Watchers fired in the last 5 iterations: [["fn: $watchCollectionWatch; newVal: 121; oldVal: 118"],["fn: $watchCollectionWatch; newVal: 124; oldVal: 121"],["fn: $watchCollectionWatch; newVal: 127; oldVal: 124"],["fn: $watchCollectionWatch; newVal: 130; oldVal: 127"],["fn: $watchCollectionWatch; newVal: 133; oldVal: 130"]]
I understand that ng-repeat attempts to match exact objects and that getLocalStorageKeys creates a new object each time it is called. However, I am puzzled as to why adding "track by $index" does not resolve this issue, as my understanding was that "track by" was designed to address this specific problem. What could be causing this error?