AngularJS的select設(shè)置默認(rèn)值
在使用Angular時(shí)候使用select標(biāo)簽時(shí)會(huì)遇到綁定數(shù)據(jù)指定默認(rèn)顯示值可這樣實(shí)現(xiàn)
<!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 : "任務(wù)" }, { id : '02', name : "日志" }, { id : '03', name : "會(huì)議" }, { id : '04', name : "學(xué)習(xí)" }, { id : '05', name : "總結(jié)" }, { id : '99', name : "其他" } ]; $scope.ZNoteVo={}; $scope.ZNoteVo.type = "03"; }); </script> </html>
當(dāng)我們選擇類型是03時(shí)則默認(rèn)是會(huì)議
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持,如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,大家共同進(jìn)步!
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注