AngularJS ng-options directive
AngularJS instance
Use array elements to fill the drop-down list:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/libs//1.4.6/"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <select ng-model="selectedName" ng-options="item for item in names"> </select> </div> <script> var app = ('myApp', []); ('myCtrl', function($scope) { $ = ["Emil", "Tobias", "Linus"]; }); </script> <p>This example demonstrates how to use it ng-options Directive fill drop-down list。</p> </body> </html>
Definition and usage
ng-optionsDirectives are used to fill the <select> element with <options> option.
ng-optionsDirectives use arrays to fill drop-down lists, most often with the ng-repeat directive.
grammar
<select ng-options="array expression"></select>
The <details> element supports this directive.
Parameter value
value | describe |
---|---|
array expression | An expression in the array that fills the option for the select element. |
The above is the compilation of AngularJS ng-options data, and will be supplemented later.