ng-repeat going into infinite loop on array of objects

39 Views Asked by At

I have an HTML block that is accessing values using ng-repeat in an object array 'items' of type:

[{
    method: 0,
    text: 'text1'
},
{
    method: 1,
    text: 'text2'
},
{
    method: 3,
    text: 'text3'
}]

Below is the HTML block:

<div class="item" ng-if="$ctrl.isHighlighted()">
    <div class="item-label">Highlighted field</div>
    <span ng-repeat="item in $ctrl.items track by $index">
        <span>{{item.text}}</span>
    </span>
</div>

The isHighlighted() method in component populates the 'items' array and returns length of the array, so the block will only be rendered if length > 0.

But I keep getting the error: Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! How can I stop ng-repeat from going into an infinte loop?

0

There are 0 best solutions below