angular中的ng-options 用法

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../js/angular-1.3.0.js" ></script>
</head>
<body>
<div ng-app="hd" ng-controller='ctrl'>
<select ng-options=" v.value as v.name for v in data" ng-model="city">
<option value=''>请选择</option>
</select>
{{city}}
</div>
<script>
var m = angular.module('hd',[]);
m.controller('ctrl',['$scope',function($scope){
$scope.city='qing hua'; //默认选中
$scope.data=[{name:'北大',value:'bei da'},{name:'清华',value:'qing hua'},{name:'南开',value:'nankai'}];
}]);
</script>
</body>
</html>

posted @ 2017-06-08 22:49  江山一族  阅读(618)  评论(0编辑  收藏  举报