Home > Web Front-end > JS Tutorial > body text

Detailed explanation of AngularJS's ng-options directive

怪我咯
Release: 2017-06-27 11:50:02
Original
957 people have browsed it

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>
Copy after login

Definition and usage

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

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

Syntax

##

# The
##

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!