|
36 | 36 | * <div ng-repeat="(key, value) in myObj"> ... </div>
|
37 | 37 | * ```
|
38 | 38 | *
|
39 |
| - * You need to be aware that the JavaScript specification does not define the order of keys |
40 |
| - * returned for an object. (To mitigate this in Angular 1.3 the `ngRepeat` directive |
41 |
| - * used to sort the keys alphabetically.) |
| 39 | + * However, there are a limitations compared to array iteration: |
42 | 40 | *
|
43 |
| - * Version 1.4 removed the alphabetic sorting. We now rely on the order returned by the browser |
44 |
| - * when running `for key in myObj`. It seems that browsers generally follow the strategy of providing |
45 |
| - * keys in the order in which they were defined, although there are exceptions when keys are deleted |
46 |
| - * and reinstated. See the [MDN page on `delete` for more info](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete#Cross-browser_notes). |
| 41 | + * - The JavaScript specification does not define the order of keys |
| 42 | + * returned for an object, so Angular relies on the order returned by the browser |
| 43 | + * when running `for key in myObj`. Browsers generally follow the strategy of providing |
| 44 | + * keys in the order in which they were defined, although there are exceptions when keys are deleted |
| 45 | + * and reinstated. See the |
| 46 | + * [MDN page on `delete` for more info](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete#Cross-browser_notes). |
47 | 47 | *
|
48 |
| - * If this is not desired, the recommended workaround is to convert your object into an array |
49 |
| - * that is sorted into the order that you prefer before providing it to `ngRepeat`. You could |
| 48 | + * - `ngRepeat` will silently *ignore* object keys starting with `$`, because |
| 49 | + * it's a prefix used by Angular for public (`$`) and private (`$$`) properties. |
| 50 | + * |
| 51 | + * - The built-in filters {@link ng.orderBy orderBy} and {@link ng.filter filter} do not work with |
| 52 | + * objects, and will throw if used with one. |
| 53 | + * |
| 54 | + * If you are hitting any of these limitations, the recommended workaround is to convert your object into an array |
| 55 | + * that is sorted into the order that you prefer before providing it to `ngRepeat`. You could |
50 | 56 | * do this with a filter such as [toArrayFilter](http://ngmodules.org/modules/angular-toArrayFilter)
|
51 | 57 | * or implement a `$watch` on the object yourself.
|
52 | 58 | *
|
|
0 commit comments