AngularJS ng-selected instruction
Definition and Usage
ng-selected
instruction setting <select>
in the list <option>
of the element selected
attribute.
if ng-selected
expression returned within the attribute true
and the option will be selected.
ng-selected
Instructions are necessary for converting values between true and false. In HTML, the selected attribute cannot be set to false (the existence of the selected attribute will select the element regardless of its value).
Example
Set the selected attribute to true:
Please click here to select BMW as your favorite car:
<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>
Syntax
<option ng-selected="expression</option>
Affected <option>
Element Support.
Parameters
Parameters | Description |
---|---|
expression | If the expression returns true, then the selected attribute of the element will be set. |