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時則默認是會議
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持,如有疑問請留言或者到本站社區交流討論,大家共同進步!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。