AngularJS Basic ng options Instructions Detailed Explanation
- 2021-07-07 06:11:24
- OfStack
AngularJS ng-options Directive
AngularJS instance
Fill the drop-down list with array elements:
<!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>
<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 to populate the drop-down list. </p>
</body>
</html>
Definition and usage
The ng-options directives are used to use the
<
options
>
Padding
<
select
>
Gets or sets the options for the.
The ng-options directive uses arrays to populate the drop-down list, most of which is used with the ng-repeat directive 1.
Grammar
<
select ng-options="array expression"
>
<
/select
>
<
details
>
Element supports this directive.
Parameter value
值 | 描述 |
---|---|
array expression | 数组中为 select 元素填充选项的表达式。 |
The above is the collation of AngularJS ng-options data, which will be supplemented in the future.