Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ng-repeat throws "Duplicates in a repeater" iterating over an object with identical values #2787

Closed
worrel opened this issue May 24, 2013 · 0 comments

Comments

@worrel
Copy link
Contributor

worrel commented May 24, 2013

Using

ng-repeat="(key,value) in myObj"

where myObj = {
age: "20",
children: "20"
}

throws "Duplicates in a repeater" error, because the default 'trackByIdFn' is calling hasKey with only the value (not the key). The generated hashes for both myObj.age and myObj.children end up as "string:20", which trips up ng-repeat.

Perhaps trackByIdFn should handle strings/numbers explicitly and use hashKey(key + value) for them? Not sure what else this impacts however.

worrel added a commit to worrel/angular.js that referenced this issue May 27, 2013
Modifies default trackByIdFn to factor both key and value into hashKey
for non-array primitive (i.e. index not provided) values

Close angular#2787
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant