angularjs 解决ng-repeat数组内重复对象报错的问题

ng-repeat 循环数组内元素时,如果数组内元素重复,angular会抛出异常: Error: [ngRepeat:dupes] http://errors.angularjs.org/1.4.3/ngRepeat/dupes?p0=record%20in%20records&p…2coachCode%22%3A%2200455532%22%2C%22%24%24hashKey%22%3A%22object%3A5%22%7D

为解决这个问题,可以在ng-repeat指令中加上track by $index,代码如下:

1 <li class="item record-item" ng-repeat="record in records track by $index"></li>

 

posted @ 2016-04-16 16:23  Hquestion  阅读(999)  评论(0编辑  收藏  举报