From 1d41e8a975d6a35d2bf56647567c054387a9d763 Mon Sep 17 00:00:00 2001 From: Boris Cherny Date: Fri, 22 May 2015 16:58:01 -0700 Subject: [PATCH] docs(ngRepeat): document that track by must be the last expression this is a point of confusion that's not well documented. see #5520 Closes #11934 --- src/ng/directive/ngRepeat.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 06180f7022ce..82c138a20d70 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -97,6 +97,15 @@ * * ``` * + *
+ * **Note:** `track by` must always be the last expression: + *
+ * ``` + *
+ * {{model.name}} + *
+ * ``` + * * # 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. @@ -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.