AngularJS的select设置默认值
在使用Angular时候使用select标签时会遇到绑定数据指定默认显示值可这样实现
<!DOCTYPE html>
<html ng-app="noteApp" ng-controller="noteCtrl">
<head>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../plugins/angular.min.js"></script>
</head>
<body ng-app="noteApp" ng-controller="noteCtrl">
<select ng-options="act.id as act.name for act in typeList"
ng-model="ZNoteVo.type"></select>
</body>
<script type="text/javascript">
angular.module("noteApp", []).controller("noteCtrl", function($scope) {
$scope.typeList = [ {
id : '01',
name : "任务"
}, {
id : '02',
name : "日志"
}, {
id : '03',
name : "会议"
}, {
id : '04',
name : "学习"
}, {
id : '05',
name : "总结"
}, {
id : '99',
name : "其他"
} ];
$scope.ZNoteVo={};
$scope.ZNoteVo.type = "03";
});
</script>
</html>
当我们选择类型是03时则默认是会议
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持,如有疑问请留言或者到本站社区交流讨论,大家共同进步!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。