Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit c72b2b2

Browse files
naomiblackchirayuk
authored andcommitted
docs(select): Update docs for InputSelect and OptionValue
1 parent 494deda commit c72b2b2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

lib/directive/ng_model_select.dart

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
part of angular.directive;
22

33
/**
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]`
66
*
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.
1010
*
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>
1817
*
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.
1920
*/
2021
@Decorator(
2122
selector: 'select[ng-model]',
@@ -88,9 +89,15 @@ class InputSelect implements AttachAware {
8889
}
8990

9091
/**
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>
9399
*
100+
* Note: See [InputSelect] for the simpler case where `option.value` is a string.
94101
*/
95102
@Decorator(selector: 'option', module: NgValue.module)
96103
class OptionValue implements AttachAware,

0 commit comments

Comments
 (0)