Recursion with ng-repeat in Angular

前端 未结 10 1267
心在旅途
心在旅途 2020-12-15 19:17

I have the following data structure for items in my sidemenu, in an Angular app based on a paid-for web site theme. The data structure is my own, and the menu is derived fro

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 20:05

    Do you mean something like this? http://jsfiddle.net/uXbn6/3639/

    JS

    angular.module("myApp", []).controller("TreeController", ['$scope',function($scope) {
    
    
        $scope.menuItems = [{
          "isNavItem": true,
          "href": "#/dashboard.html",
          "text": "Dashboard"
        }, {
          "isNavItem": true,
          "href": "javascript:;",
          "text": "AngularJS Features",
          "subItems": [{
            "href": "#/ui_bootstrap.html",
            "text": " UI Bootstrap"
          }, {
            "isNavItem": true,
            "href": "javascript:;",
            "text": "AngularJS Features",
            "subItems": [{
              "href": "#/ui_bootstrap.html",
              "text": " UI Bootstrap"
            }]
          }]
        }, {
          "isNavItem": true,
          "href": "javascript:;",
          "text": "jQuery Plugins",
          "subItems": [{
            "href": "#/form-tools",
            "text": " Form Tools"
          }, {
            "isNavItem": true,
            "href": "javascript:;",
            "text": " Datatables",
            "subItems": [{
              "href": "#/datatables/managed.html",
              "text": " Managed Datatables"
            }]
          }]
        }];
      }]);
    

    HTML

      
    
      

提交回复
热议问题