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="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body ng-app="">Click the check box to select BMW options: <input type="checkbox" ng-model="mySel"><p>I like car:</p><select> <option>Volvo</option> <option ng-selected="mySel">BMW</option> <option>Ford</option> </select></body></html>
Definition and usage
The ng-selected directive is used to set the selected property of the <option> element in the <select> list.
The expression of the ng-selected property returns true and 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!