Skip to content

Commit 3b89e4e

Browse files
jbdeboerIgorMinar
authored andcommitted
docs(minerr): Adds a description for ngRepeat.dupes
Closes angular#3439
1 parent fe18767 commit 3b89e4e

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
@ngdoc error
22
@name ngRepeat:dupes
3-
@fullName Duplicate Repeater Key
3+
@fullName Duplicate Key in Repeater
44
@description
5+
6+
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.
7+
8+
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).
9+
10+
For example the issue can be triggered by this *invalid* code:
11+
12+
```
13+
<div ng-repeat="value in [4, 4]"></div>
14+
```
15+
16+
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.
17+
18+
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:
19+
20+
```
21+
<div ng-repeat="value in [4, 4] track by $index"></div>
22+
```

0 commit comments

Comments
 (0)