think123 think123 - 1 year ago 75
AngularJS Question

Duplicates in a repeater are not allowed, index already specified

I'm having an issue with AngularJS repeaters:

<table class="data_table" style="margin: 0 5px; width: calc(100% - 10px);">
<th ng-repeat="date in activitiesRangeInfo.labels">{{date | date: 'd/MM'}}</th>
<tr ng-repeat="activity in activitiesRangeInfo.generated_datasets track by $index">
<td align="center" ng-repeat="inner in activitiesRangeInfo.generated_datasets[$index] track by $index">
{{inner | number: 1}}

and this data set:

$scope.activitiesRangeInfo = {
all_activities: ["Tennis"],
generated_datasets: [[0, 0, 420, 0]],
labels: JSON.parse('["2016-10-22T13:00:00.000Z","2016-10-23T13:00:00.000Z","2016-10-24T13:00:00.000Z","2016-10-25T13:00:00.000Z"]')

and this error:

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: inner in activity track by $indexb, Duplicate key: undefined, Duplicate value: 0

Please have a look and advise as to what's wrong.

Answer Source

$indexb isn't valid because it is an Angular defined property. Just use $index. If you want to define your own see this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download