AngularJS ng-options directive
Definition and Usage
ng-options
The directive uses <options>
fill lt;select>
elements.
ng-options
directives use arrays to fill dropdown lists. In many cases, using ng-repeat
directives make it easier, but using ng-options
you have greater flexibility when using directives.
Example
Through using items in the array to fill options in the dropdown list:
<div ng-app="myApp" ng-controller="myCtrl"> <select ng-model="selectedName" ng-options="item for item in names"></select> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) {}} $scope.names = ["Emil", "Tobias", "Linus"]; }); </script>
Γραμματική
<select ng-options="array expression"></select>
υποστηρίζεται από <select>
Υποστήριξη στο στοιχείο.
Παράμετροι
Παράμετροι | Περιγραφή |
---|---|
array expression |
Έκφραση που επιλέγει συγκεκριμένες ενότητες της ακολουθίας για να γεμίσει το στοιχείο select. Λέξις έκφρασης: label for value in array select as label for value in array label group by group for value in array label disable when disable for value in array label group by group for value in array track by expression label disable when disable for value in array track by expression label for value in array | orderBy expression track by expression |