1. 程式人生 > >Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.報錯

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.報錯

意思 重復 span error ror -s ont ica dex

在angular的項目裏,一不小心就會出現這個錯誤[ngRepeat:dupes] ,這個問題是因為內容有重復引起的解決起來挺簡單

在對應的ng-repeat指令中增加track by $index,意思是用索引值識別

例: 

  <p ng-repeat="item in ages track by $index">
    {{item}}
  </p>

這樣,報錯就消失啦

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.報錯