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时则默认是会议 ![输入图片说明](https://static.oschina.net/uploads/img/201707/03162339_D2LP.png "在这里输入图片标题")

转载于:https://my.oschina.net/u/3101544/blog/1142875

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值