This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 23
23
* Creating aliases for these properties is possible with {@link ng.directive:ngInit `ngInit`}.
24
24
* This may be useful when, for instance, nesting ngRepeats.
25
25
*
26
+ * # Iterating over object properties
27
+ *
28
+ * It is possible to get `ngRepeat` to iterate over the properties of an object using the following
29
+ * syntax:
30
+ *
31
+ * ```js
32
+ * <div ng-repeat="(key, value) in myObj"> ... </div>
33
+ * ```
34
+ *
35
+ * You need to be aware that the JavaScript specification does not define what order
36
+ * it will return the keys for an object. In order to have a guaranteed deterministic order
37
+ * for the keys, Angular versions up to and including 1.3 **sort the keys alphabetically**.
38
+ *
39
+ * If this is not desired, the recommended workaround is to convert your object into an array
40
+ * that is sorted into the order that you prefer before providing it to `ngRepeat`. You could
41
+ * do this with a filter such as [toArrayFilter](http://ngmodules.org/modules/angular-toArrayFilter)
42
+ * or implement a `$watch` on the object yourself.
43
+ *
44
+ * In version 1.4 we will remove the sorting, since it seems that browsers generally follow the
45
+ * strategy of providing keys in the order in which they were defined, although there are exceptions
46
+ * when keys are deleted and reinstated.
47
+ *
48
+ *
26
49
* # Special repeat start and end points
27
50
* To repeat a series of elements instead of just one parent element, ngRepeat (as well as other ng directives) supports extending
28
51
* the range of the repeater by defining explicit start and end points by using **ng-repeat-start** and **ng-repeat-end** respectively.
You can’t perform that action at this time.
0 commit comments