Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ea18976

Browse files
committed
docs(select): clarify policy of track by and select as
1 parent d71fb6f commit ea18976

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ng/directive/select.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ var ngOptionsMinErr = minErr('ngOptions');
3838
* <div class="alert alert-info">
3939
* **Note:** Using `select as` will bind the result of the `select as` expression to the model, but
4040
* the value of the `<select>` and `<option>` html elements will be either the index (for array data sources)
41-
* or property name (for object data sources) of the value within the collection.
41+
* or property name (for object data sources) of the value within the collection.
4242
* </div>
4343
*
44-
* **Note:** Using `select as` together with `trackexpr` is not possible (and will throw an error).
44+
* **Note:** Using `select as` together with `trackexpr` is not recommended.
4545
* Reasoning:
4646
* - Example: &lt;select ng-options="item.subItem as item.label for item in values track by item.id" ng-model="selected"&gt;
47-
* values: [{id: 1, label: 'aLabel', subItem: {name: 'aSubItem'}}, {id: 2, label: 'bLabel', subItem: {name: 'bSubItemß'}}],
47+
* values: [{id: 1, label: 'aLabel', subItem: {name: 'aSubItem'}}, {id: 2, label: 'bLabel', subItem: {name: 'bSubItem'}}],
4848
* $scope.selected = {name: 'aSubItem'};
49-
* - track by is always applied to `value`, with purpose to preserve the selection,
49+
* - track by is always applied to `value`, with the purpose of preserving the selection,
5050
* (to `item` in this case)
5151
* - to calculate whether an item is selected we do the following:
5252
* 1. apply `track by` to the values in the array, e.g.

0 commit comments

Comments
 (0)