码迷,mamicode.com
首页 > 其他好文 > 详细

angular中的ng-options 用法

时间:2017-06-08 23:36:12      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:-o   option   body   har   data   function   app   city   清华   

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

angular中的ng-options 用法

标签:-o   option   body   har   data   function   app   city   清华   

原文地址:http://www.cnblogs.com/qiyc/p/6965191.html

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