AngularJS ng-selected directive
AngularJS instance
Get the selected options:
Click the check box to select BMW options:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/libs//1.4.6/"></script> </head> <body ng-app=""> Click the check box to select BMW Options: <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> </body> </html>
Definition and usage
ng-selected Directives are used to set the selected property of the <option> element in the <select> list.
ng-selected If the expression of the property returns true, the option is selected.
grammar
<option ng-selected="expression"></option>
The <option> element supports this directive.
Parameter value
value | describe |
---|---|
expression | If the expression is true, the option is selected |
The above is the basic information sorting for the AngularJS ng-selected instruction. We will continue to sort it out later. Thank you for your support!