Improve this Doc View Source select
- directive in module ng
HTML SELECT
element with angular data-binding.
ngOptions
The ngOptions
attribute can be used to dynamically generate a list of <option>
elements for the <select>
element using the array or object obtained by evaluating the ngOptions
comprehension_expression.
When an item in the <select>
menu is selected, the array element or object property represented by the selected option will be bound to the model identified by the ngModel
directive.
ngModel
compares by reference, not value. This is important when binding to an array of objects. See an example in this jsfiddle. Optionally, a single hard-coded <option>
element, with the value set to an empty string, can be nested into the <select>
element. This element will then represent the null
or "not selected" option. See example below for demonstration.
ngOptions
provides an iterator facility for the <option>
element which should be used instead of ngRepeat when you want the select
model to be bound to a non-string value. This is because an option element can only be bound to string values at present. Directive Info
- This directive executes at priority level 0.
Usage
- as element:
<select ng-model="" [name=""] [required=""] [ng-required=""] [ng-options=""]> ... </select>
Arguments
Param | Type | Details |
---|---|---|
ngModel | string | Assignable angular expression to data-bind to. |
name (optional) | string | Property name of the form under which the control is published. |
required (optional) | string | The control is considered valid only if value is entered. |
ngRequired (optional) | string | Adds |
ngOptions (optional) | comprehension_expression | in one of the following forms:
Where:
|
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.2.32/docs/api/ng/directive/select