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時則默認是會議
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持,如有疑問請留言或者到本站社區交流討論,大家共同進步!
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com