ng-repeat duplicated on item change

169 views Asked by At

I have an angular application with sets of array items "array_var". When I push new sets of array to array_var, I noticed that the ng-repeat in my html creates a duplicate ng-repeat.

enter image description here

everytime I push new array to the array_var there is also another duplicate ng-repeat created. Sample ng-repeat:

<div ng-repeat="d in icons track by $index" class="icons-holder">
    <div class="col-lg-12 col-md-12 col-sm-12 sub-category text-center" ng-hide="d.date == icons[$index-1].date">
        <div class="searchTag-holder pad-left-25 pad-right-25 d-inline-b">
            <ul>
                <li class="searchTag">
                    {! d.date !}
                </li>
            </ul>
        </div>
    </div>
</div>
1

There are 1 answers

0
zelda11 On

The repeated attribute is normal in this feature, you can see the example here: https://www.w3schools.com/angular/tryit.asp?filename=try_ng_ng-repeat2 (Inspect element) If you want to avoid that attribute you could repeat the element with pure javascript/typescript.

This link has more details: https://www.w3schools.com/angular/ng_ng-repeat.asp