Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.报错

Posted 额爷

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.报错相关的知识,希望对你有一定的参考价值。

在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.报错的主要内容,如果未能解决你的问题,请参考以下文章