首页 > 代码库 > angularjs select

angularjs select

<html><head>	<meta charset="utf-8">	<title>select 测试页面</title>	<script src="http://www.mamicode.com/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="http://www.mamicode.com/{{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