码迷,mamicode.com
首页 > Web开发 > 详细

angularjs select

时间:2016-12-04 16:22:39      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:sha   repeat   options   angular   with   script   app   cti   value   

<html>
<head>
	<meta charset="utf-8">
	<title>select 测试页面</title>
	<script src="angular1.5.8.min.js"></script>
</head>
<body ng-app="app">
<div ng-controller="getnames">
	<p>with ng-option,这种方式可以取到一个对象</p>
		<select ng-model="selectedPeople" ng-options="people.name for people in peoples"></select>
	    your choice is :{{selectedPeople.name}}

	<!-------------------------------------------------------------------------------------------->    
	<p>without ng-option,这种方式只能取到一个字符串</p>
		<select ng-model="selectedName">
			<option  ng-repeat="people in peoples" value="{{people.age}}">{{people.name}}</option>
		</select>
	    your choice is :{{selectedName}}
</div>
</body>
<script type="text/javascript">
	var app =angular.module("app",[]);
	app.controller("getnames",function($scope){
		$scope.peoples=[{name:"quannan",age:"100"},{name:"shenzhen",age:"1200"},{name:"shnaghai",age:"1003"}];
		//$scope.names=["quannan","shenzhen","shanghai"];
	});
</script>
</html>

  

angularjs select

标签:sha   repeat   options   angular   with   script   app   cti   value   

原文地址:http://www.cnblogs.com/hrx-star/p/6130682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!