Angular JS ng-repeat Error: [ngRepeat:dupes]

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Common use of NG repeat:

<div class="form-group" ng-repeat="item in items"></div>

But there is a situation in this case, that is, error: [NgR] epeat:dupes ]Wrong

ng-repeat does not allow as like as two peas of two data


This kind of situation will report an error

$scope.items = [1,1,1,1,2,2,2,2];


<div class="form-group" ng-repeat="item in items track by $index"></div>

Add “track by $Index” to solve this problem

But after that, there will be a problem. If you have input fields in ng repeat, and you use ng model = “item. XX”

Repeat the value, as long as you modify any one of them, others will also change with it

Similar Posts: