English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js></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 = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.names = ['Emil', 'Tobias', 'Linus']; }); </script> <p>This example demonstrates how to use the ng-options directive fills the dropdown list.</p> </body> </html>Test to see ‹/›
ng-options This directive is used to fill the options of the <select> element with <options>.
ng-options This directive uses an array to fill the dropdown list, usually together with ng-repeat Used together with directives.
<select ng-options="array expression"></select>
The <details> element supports this directive.
Value | Description |
---|---|
array expression | Expression to fill options for select elements in an array. |