AngularJS ng-selected
Directive
AngularJS Example
Get the selected option:
Click the checkbox to select the BMW option: <input type="checkbox" ng-model="mySel">
<p>My favorite car:</p><select><option>Volvo</option>
<option ng-selected="mySel">BMW</option><option>Ford</option>
</select>
Definition and Usage
The ng-selected directive is used to set the selected
attribute of the <option>
element in a <select>
list.
The option is selected if the expression of the ng-selected
attribute returns true.
Syntax
The <option>
element supports this directive.
Parameter Values
Value | Description |
---|---|
expression | The option is selected if the expression is true |