My goal is to retrieve the normalized value of an array associated with different groups without altering the original array items. Instead, I am creating new objects for each group's normalized items.
$scope.nomalizedItems = function (groupid) {
var groupItems = $scope.originalItems.filter(function (item) {
return item.groupid == groupid
});
var values = groupItems.map(function (item) {
return item.value;
});
var maxValue = Math.max.apply(null, values);
return groupItems.map(function (item) {
return {
id: item.id,
normalizedValue: item.value / maxValue
};
});
};
Although this logic seems straightforward, I keep encountering an error in AngularJS that says "
[$rootScope:infdig] 10 $digest() iterations reached. Aborting!
" even after adding "track by item.id
" in the ng-repeat expression.
Any suggestions on how to resolve this problem? Thank you!