我收到了从服务请求返回的以下 json 数据:
{
"entries": [{
"id": 2081,
"name": "BM",
"niceName": "bodmas"
}]
}, {
"id": 8029,
"name": "Mas",
"niceName": "Masm"
}]
}],
"count": 2
}
我正在尝试在 html 中使用以下代码来循环访问这些数据:
<option ng-repeat="entry in entries" value="{{entry.name}}">{{entry.name}}</option>
当我运行代码时出现以下错误:
Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: entry in entries, Duplicate key: string:c
以下是我的控制器的代码:
myApp.controller("MyController", ['$scope', '$http', '$log', function($scope, $http, $log){
...
$http.get('https://myServiceURL').success(function(data){
$scope.entries = data;
});
}]);
有人可以帮助我理解为什么我会收到该错误吗?