在这里,我试图通过Angular Js从Mvc中的Wcf-Rest服务访问数据但是当我尝试绑定数据时通过错误错误:[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: ee in HelloData, Duplicate key: string:r, Duplicate value: r
<table class="table table-bordered table-hover tab-content">
<tr>
<th><b>Id</b></th>
<th><b>Name</b></th>
</tr>
<tr ng-repeat="ee in HelloData">
<td>{{ee.Id}}</td>
<td>{{ee.Name}}</td>
</tr>
</table>
Ctrl.Js
$scope.CallServiceDb = function () {
alert('in cntrl');
var sss = MywcfService.GetData();
sss.then(function (d) {
$scope.HelloData = d.data;
})
Service.Js
var RestApi = "http://localhost:9706/EmployeeService.svc";
this.GetData = function () {
alert('in Service');
var sss = $http({
url: RestApi+"/Hell",
method: "GET",
})
return sss;
}
答案 0 :(得分:1)
如果您的数据源有重复的标识符,您可以按$ index跟踪
<tr ng-repeat="ee in HelloData track by $index">
<td>{{ee.Id}}</td>
<td>{{ee.Name}}</td>
</tr>