From b9e5eaf66936f53a9bd9455f42d11050bed73aaa Mon Sep 17 00:00:00 2001 From: Steve Shaffer Date: Wed, 26 Nov 2014 07:30:08 -0800 Subject: [PATCH] docs(select): Updated ngOptions track by examples Made the example shown consistent with the advice above it regarding not using `select as` and `track by` in the same comprehension expression. Also changed references to `trackexpr` to `track by` since `trackexpr` is not defined except in the examples. Added filter + track by example for ngOptions The documentation for ngRepeat includes such an example specifying the proper order for filters and and "track by" clauses in the comprehension expression, but these docs for ngOptions do not. --- src/ng/directive/select.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index a7433fb8..d889ea3f 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -42,9 +42,9 @@ var ngOptionsMinErr = minErr('ngOptions'); * or property name (for object data sources) of the value within the collection. If a `track by` expression * is used, the result of that expression will be set as the value of the `option` and `select` elements. * - * ### `select as` with `trackexpr` + * ### `select as` with `track by` * - * Using `select as` together with `trackexpr` is not recommended. Reasoning: + * Using `select as` together with `track by` is not recommended. Reasoning: * * - Example: <select ng-options="item.subItem as item.label for item in values track by item.id" ng-model="selected"> * values: [{id: 1, label: 'aLabel', subItem: {name: 'aSubItem'}}, {id: 2, label: 'bLabel', subItem: {name: 'bSubItem'}}], @@ -69,8 +69,10 @@ var ngOptionsMinErr = minErr('ngOptions'); * * for array data sources: * * `label` **`for`** `value` **`in`** `array` * * `select` **`as`** `label` **`for`** `value` **`in`** `array` - * * `label` **`group by`** `group` **`for`** `value` **`in`** `array` - * * `select` **`as`** `label` **`group by`** `group` **`for`** `value` **`in`** `array` **`track by`** `trackexpr` + * * `label` **`group by`** `group` **`for`** `value` **`in`** `array` + * * `label` **`group by`** `group` **`for`** `value` **`in`** `array` **`track by`** `trackexpr` + * * `label` **`for`** `value` **`in`** `array` | orderBy:`orderexpr` **`track by`** `trackexpr` + * (for including a filter with `track by`) * * for object data sources: * * `label` **`for (`**`key` **`,`** `value`**`) in`** `object` * * `select` **`as`** `label` **`for (`**`key` **`,`** `value`**`) in`** `object`