|
1 | 1 | part of angular.directive;
|
2 | 2 |
|
3 | 3 | /**
|
4 |
| - * HTML [SELECT] element with angular data-binding if used with |
5 |
| - * [NgModel]. |
| 4 | + * Modifies the behavior of the HTML `<select>` element to perform data binding between the |
| 5 | + * `option.value` attribute and the model. `Selector: select[ng-model]` |
6 | 6 | *
|
7 |
| - * The [NgModel] will receive the currently selected item. The binding |
8 |
| - * is performed on the [OPTION].[value] property. An empty [OPTION].[value] is |
9 |
| - * treated as null. |
| 7 | + * An empty `option.value` is treated as null. If the model specifies a value which does not map |
| 8 | + * to an existing option, a new unknown option is inserted into the list. Once the model again |
| 9 | + * points to an existing option, the unknown option is removed. |
10 | 10 | *
|
11 |
| - * If you the model contains value which does not map to any [OPTION] then a new |
12 |
| - * unknown [OPTION] is inserted into the list. Once the model points to an |
13 |
| - * existing [OPTION] the unknown [OPTION] is removed. |
14 |
| - * |
15 |
| - * Because [OPTION].[value] attribute is a string, the model is bound to a |
16 |
| - * string. If there is need to bind to an object then [OptionValue] |
17 |
| - * should be used. |
| 11 | + * # Example |
| 12 | + * <select ng-model="robot"> |
| 13 | + * <option value="Marvin" selected>Marvin</option> |
| 14 | + * <option value="Speedy">Speedy</option> |
| 15 | + * <option value="Tik-Tok">Tik-Tok</option> |
| 16 | + * </select> |
18 | 17 | *
|
| 18 | + * Note: The `option.value` attribute for the `<select>` element is defined as a string. To bind to |
| 19 | + * an object for `option.value`, see the [OptionValue] directive. |
19 | 20 | */
|
20 | 21 | @Decorator(
|
21 | 22 | selector: 'select[ng-model]',
|
@@ -88,9 +89,15 @@ class InputSelect implements AttachAware {
|
88 | 89 | }
|
89 | 90 |
|
90 | 91 | /**
|
91 |
| - * Since the [value] attribute of the [OPTION] can only be a string, Angular |
92 |
| - * provides [ng-value] which allows binding to any expression. |
| 92 | + * Modifies the behavior of the HTML `<option>` element to perform data binding between an |
| 93 | + * expression for the `option.value` attribute and the model. `Selector: option[ng-value]` |
| 94 | + * |
| 95 | + * # Example |
| 96 | + * <select ng-model="robot"> |
| 97 | + * <option ng-repeat "r in robots" ng-value="r">{{r.name}}</option> |
| 98 | + * </select> |
93 | 99 | *
|
| 100 | + * Note: See [InputSelect] for the simpler case where `option.value` is a string. |
94 | 101 | */
|
95 | 102 | @Decorator(selector: 'option', module: NgValue.module)
|
96 | 103 | class OptionValue implements AttachAware,
|
|
0 commit comments