WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS ng-options Directive


Example

Fill choices in a dropdown list by utilizing the things of an array:

<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedName" ng-options="item for thing in names"></select>
</div>

<script>
var application = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.names = ["Emil", "Tobias", "Linus"];
});
</script>
Try it yourself »

Definition and Usage

The ng-options order fills a <select> component with <options>.

The ng-options order utilizes an exhibit to fill the dropdown list. Much of the time it is less demanding to utilize the ng-repeat mandate, yet you have greater adaptability when utilizing the ng-options directive.


Syntax

<select ng-options="array expression"></select>

Supported by the <select> element.


Parameter Values

Value Description
array expression An articulation that chooses the predefined parts of an exhibit to fill the select element.

Legal expressions:

label for value in array

select as label for value in array

label
group by group for value in array

label
crippled when disable for value in array

label
bunch by group for value in array track by expression

label
impaired when disable for value in array track by expression

label
for value in array | orderBy expression track by expression