轉載:http://segmentfault.com/q/1010000000405730<div?ng-repeat="links?in?slides">????<div?ng-repeat="link?in?links?track?by?$index">`link`.`name`</div></div>

Error: [ngRepeat:dupes]這個出錯提示具體到題主的情況,意思是指數組中有2個以上的相同數字。ngRepeat不允許collection中存在兩個相同Id的對象

For example:?item in items?is equivalent to?item in items track by $id(item). This implies that the DOM elements will be associated by item identity in the array.

對于數字對象來說,它的id就是它自身的值,因此,數組中是不允許存在兩個相同的數字的。為了規避這個錯誤,需要定義自己的track by表達式。例如:item in items track by item.id或者item in items track by fnCustomId(item)。嫌麻煩的話,直接拿循環的索引變量$index來用item in items track by $index