angularjs select

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

  

posted @ 2016-12-04 13:42  南修子  阅读(217)  评论(0编辑  收藏  举报