I'm currently facing the infinite digest loop error which I need some help/advice with.
So I've read the docs as well as posts on StackOverflow and I think i understand the issue - if someone could also confirm - it's essentially because something in the $scope is changing a fair number of times.
Assuming what I understand above is correct - I'm unsure on how to solve this and any advice would be appreciated.
The code I have looks like this:
HTML Side
<ul class="no-bullet" ng-repeat=“person in persons”>
<li>
<div class="progressBar" ng-style="{background: styleBuilder(person.options)}"></div>
</li>
</ul>
And in my controller
(for context: personsArray is what is passed from the HTML side and the for loop is used to update an array that contains numbers into percentages so ['classA: 8', 'classB: 2'] becomes ['classA: 75', 'classB: 25'] (I've tested this and it works)
$scope.styleBuilder = function (optionsArray){
for (var index in personsArray){
proportion = parseInt(personsArray[index].split(':')[1])/sumOfAllValues;
if (isNaN(proportion) ){
proportion = 0;
}
personsArray[index] = personsArray[index].substring(0, personsArray[index].indexOf(':'));
personsArray[index] = personsArray[index] + ' : ' + proportion*100;
}
}
Thanks.
(person.options)in thatng-repeatis used to style accordingly.personsArray[index] = personsArray[index] + ' : ' + proportion*100;