[ 登录注册 ]

yuyan

AngularJS之下拉框(方式二)

2016-08-25 22:32:54 admin 返回上一页

1、问题背景

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


2、实现源码

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

3、问题说明

     ng-repeat指令可以重复数据

     


文章来源:http://www.bozhiyue.com/web/yuyan/2016/0825/433291.html
返回上一页    返回分类 上一篇:   下一篇:
相关