I'm iterating over elements in a list via an ng-repeat-start(-end). I'm trying to dynamically add a class to the icon based on it type. The problem is that the code within the getClass(...)
seems to be getting executed multiple times.
Here's the HTML.
<li style="display:none;" data-ng-repeat-start="entry in entries"></li>
<li>
<i class="fa" data-ng-class="getIconClass(entry)"></i>
<span data-ng-bind="entry.name"></span>
</li>
<li style="display:none;" data-ng-repeat-end></li>
Here's the controller function.
$scope.getIconClass = function(entry) {
console.log('In getIconClass()');
if(entry.type === 'SYSTEM') {
return 'fa-laptop';
} else {
return 'fa-user';
}
}
When the loop executes, console.log('In getIconClass()')
prints out double for the amount of entries that are in the list (4 times for 2 entries, 8 times for 4 entries, etc).
Any thoughts on why this might be occurring? Does passing the entire entity and poking at properties cause the scope to be reevaluated and thus, the view re-rendered for some reason?
Thanks.