AngularJS之下拉框(方式二)

前端之家收集整理的这篇文章主要介绍了AngularJS之下拉框(方式二)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_404_1@1、问题背景

@H_404_1@ select下拉框里option组装成下拉框,这里利用ng-repeat指令来创建

@H_404_1@

@H_404_1@2、实现源码

@H_404_1@

<!DOCTYPE html>
<html>
	<head>
		<Meta charset="UTF-8">
		<title>AngularJS之下拉框(方式二)</title>
		<script type="text/javascript" src="../js/angular.min.js" ></script>
		<script>
			var app = angular.module("secondApp",[]);
			app.controller("secondCon",function($scope){
				$scope.trees = ["松树","樟树","枫树","枣树","桃树"];
			});
		</script>
	</head>
	<body>
		<div ng-app="secondApp" ng-controller="secondCon">
			<select style="width: 200px;">
				<option ng-repeat="tree in trees">{{tree}}</option>
			</select>
		</div>
	</body>
</html>

@H_404_1@3、问题说明

@H_404_1@ ng-repeat指令可以重复数据

@H_404_1@

原文链接:https://www.f2er.com/angularjs/149021.html

猜你在找的Angularjs相关文章