您好,登錄后才能下訂單哦!
小編給大家分享一下AngularJS如何實現的select二級聯動下拉菜單功能,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
1、js屬于一種解釋性腳本語言;2、在絕大多數瀏覽器的支持下,js可以在多種平臺下運行,擁有著跨平臺特性;3、js屬于一種弱類型腳本語言,對使用的數據類型未做出嚴格的要求,能夠進行類型轉換,簡單又容易上手;4、js語言安全性高,只能通過瀏覽器實現信息瀏覽或動態交互,從而有效地防止數據的丟失;5、基于對象的腳本語言,js不僅可以創建對象,也能使用現有的對象。
具體如下:
<!DOCTYPE html> <html ng-app> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <script src="../script/angular.js"></script> <body ng-controller="Controller"> <div>所屬分類: <select ng-model="selected1" ng-options="m.roleName for m in classification1" ng-change="changeClassification(selected1)"> <option value="">-- 請選擇 --</option> </select> <select ng-model="selected2" ng-options="m.roleName for m in classification2"> <option value="">-- 請選擇 --</option> </select> </div> </body> <script> var contantCroleList = [ { "roleName" : "軟件開發", "roleId" : "role1", "children" : [ { "roleName" : "軟件AAA", "roleId" : "role11", "children" : [] }, { "roleName" : "軟件BBB", "roleId" : "role12", "children" : []}, { "roleName" : "軟件CCC", "roleId" : "role12", "children" : []}, { "roleName" : "軟件DDD", "roleId" : "role12", "children" : []}, { "roleName" : "軟件EEE", "roleId" : "role12", "children" : []}, { "roleName" : "軟件FFF", "roleId" : "role12", "children" : []} ]}, { "roleName" : "硬件開發", "roleId" : "role2", "children" : [ { "roleName" : "硬件AAA", "roleId" : "role21", "children" : [] }, { "roleName" : "硬件BBB", "roleId" : "role22", "children" : []}, { "roleName" : "硬件CCC", "roleId" : "role23", "children" : []}, { "roleName" : "硬件DDD", "roleId" : "role24", "children" : []}, { "roleName" : "硬件EEE", "roleId" : "role25", "children" : []}, { "roleName" : "硬件FFF", "roleId" : "role26", "children" : []} ]}, { "roleName" : "嵌入式開發", "roleId" : "role3", "children" : [ { "roleName" : "嵌入式AAA", "roleId" : "role31", "children" : [] }, { "roleName" : "嵌入式BBB", "roleId" : "role32", "children" : []}, { "roleName" : "嵌入式CCC", "roleId" : "role33", "children" : []}, { "roleName" : "嵌入式DDD", "roleId" : "role34", "children" : []}, { "roleName" : "嵌入式EEE", "roleId" : "role35", "children" : []}, { "roleName" : "嵌入式FFF", "roleId" : "role36", "children" : []} ]} ]; function Controller($scope) { $scope.classification1 = contantCroleList; $scope.changeClassification = function (selected1) { $scope.classification2 = selected1.children; }; } </script> </html>
以上是“AngularJS如何實現的select二級聯動下拉菜單功能”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。