Home >Web Front-end >JS Tutorial >Detailed explanation of AngularJS's ng-options directive

Detailed explanation of AngularJS's ng-options directive

怪我咯
怪我咯Original
2017-06-27 11:50:021039browse

This article mainly introducesAngularJS ng-options directive. Here, the knowledge of ng-options directive is compiled in detail, and detailed code examples are attached. Friends in need can refer to it

AngularJS ng-options Directive

AngularJS Example

Filled using arrayelements Drop-down list:

<!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>

<p ng-app="myApp" ng-controller="myCtrl">

<select ng-model="selectedName" ng-options="item for item in names">
</select>

</p>

<script>
var app = angular.module(&#39;myApp&#39;, []);
app.controller(&#39;myCtrl&#39;, function($scope) {
  $scope.names = ["Emil", "Tobias", "Linus"];
});
</script>

<p>该实例演示了如何使用 ng-options 指令填充下拉列表。</p>

</body>
</html>

Definition and usage

##ng-options directive is used to use 60a61265e5aae0b471944c5e0c03124c element.

ng-options directive uses an array to populate a dropdown list, most often used in conjunction with the ng-repeat directive.

Syntax

##21e8345d5e7f4691636d757740267e8518bb6ffaf0152bbe49cd8a3620346341

# The
##a5e9d42b316b6d06c62de0deffc36939 element supports this directive.


Parameter value

ValueDescriptionarray expressionThe that fills the options for the select element in the array. The above is the compilation of AngularJS ng-options information, and we will continue to add more later.
expression

The above is the detailed content of Detailed explanation of AngularJS's ng-options directive. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn