报错信息:
"Error: [ngRepeat:dupes] http://errors.angularjs.org/1.6.2/ngRepeat/dupes?p0=projectFeaturesItem%20in%20projectFeaturesData&p1=string%3A%E5%A4%A7%E6%95%B0%E6%8D%AE&p2=%E5%A4%A7%E6%95%B0%E6%8D%AE
所循环数组
$scope.dataList = [1,2,1];
出错原因
这是因为ng-Repeat不允许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表达式。
// 业务上自己生成唯一的id
item in items track by item.id
//或者直接拿循环的索引变量$index来用
item in items track by $index