Skip to content

Commit

Permalink
docs(ngRepeat): document that track by must be the last expression
Browse files Browse the repository at this point in the history
this is a point of confusion that's not well documented. see angular#5520

Closes angular#11934
  • Loading branch information
bcherny authored and netman92 committed Aug 8, 2015
1 parent 610414f commit 2d7cb9b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/ng/directive/ngRepeat.js
Expand Up @@ -97,6 +97,15 @@
* </div>
* ```
*
* <div class="alert alert-warning">
* **Note:** `track by` must always be the last expression:
* </div>
* ```
* <div ng-repeat="model in collection | orderBy: 'id' as filtered_result track by model.id">
* {{model.name}}
* </div>
* ```
*
* # Special repeat start and end points
* To repeat a series of elements instead of just one parent element, ngRepeat (as well as other ng directives) supports extending
* the range of the repeater by defining explicit start and end points by using **ng-repeat-start** and **ng-repeat-end** respectively.
Expand Down Expand Up @@ -168,8 +177,9 @@
* which can be used to associate the objects in the collection with the DOM elements. If no tracking expression
* is specified, ng-repeat associates elements by identity. It is an error to have
* more than one tracking expression value resolve to the same key. (This would mean that two distinct objects are
* mapped to the same DOM element, which is not possible.) If filters are used in the expression, they should be
* applied before the tracking expression.
* mapped to the same DOM element, which is not possible.)
*
* Note that the tracking expression must come last, after any filters, and the alias expression.
*
* For example: `item in items` is equivalent to `item in items track by $id(item)`. This implies that the DOM elements
* will be associated by item identity in the array.
Expand Down

0 comments on commit 2d7cb9b

Please sign in to comment.