diff options
| author | James deBoer | 2013-08-01 17:21:54 -0700 |
|---|---|---|
| committer | Igor Minar | 2013-08-07 09:22:21 -0700 |
| commit | 3b89e4eef13be0ea25758f021de5eb38152cd0bf (patch) | |
| tree | 190bbbb54571bb69a77f859a8e6a3ab6d0ea053a /docs/content/error/ngRepeat | |
| parent | fe187674b5bace9d738b18a2b6a994d7e253b9ce (diff) | |
| download | angular.js-3b89e4eef13be0ea25758f021de5eb38152cd0bf.tar.bz2 | |
docs(minerr): Adds a description for ngRepeat.dupes
Closes #3439
Diffstat (limited to 'docs/content/error/ngRepeat')
| -rw-r--r-- | docs/content/error/ngRepeat/dupes.ngdoc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/docs/content/error/ngRepeat/dupes.ngdoc b/docs/content/error/ngRepeat/dupes.ngdoc index eb25ec67..42d4c77a 100644 --- a/docs/content/error/ngRepeat/dupes.ngdoc +++ b/docs/content/error/ngRepeat/dupes.ngdoc @@ -1,4 +1,22 @@ @ngdoc error @name ngRepeat:dupes -@fullName Duplicate Repeater Key +@fullName Duplicate Key in Repeater @description + +Occurs if there are duplicate keys in an {@link api/ng.directive:ngRepeat ngRepeat} expression. Duplicate keys are banned because AngularJS uses keys to associate DOM nodes with items. + +By default, collections are keyed by reference which is desirable for most common models but can be problematic for primitive types that are interned (share references). + +For example the issue can be triggered by this *invalid* code: + +``` +<div ng-repeat="value in [4, 4]"></div> +``` + +To resolve this error either ensure that the items in the collection have unique identity of use the `track by` syntax to specify how to track the association between models and DOM. + +To resolve the example above can be resolved by using `track by $index`, which will cause the items to be keyed by their position in the array instead of their value: + +``` +<div ng-repeat="value in [4, 4] track by $index"></div> +``` |
