How to put ng-repeat inside ng-repeat for n number of times

前端 未结 2 1597
死守一世寂寞
死守一世寂寞 2020-12-31 21:30

I have a JSON object having nested nodes, which can go on for any number of level. I need to display the content of a node on click of it\'s parent\'s node. It would look so

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 21:49

    Try This

    var jimApp = angular.module("mainApp",  []);
    
    jimApp.controller('mainCtrl', function($scope){
      $scope.nodes = [
            {
              "id": "id of the concept model",
              "name": "Curcumin",
              "type": "conceptmodel",
              "node": [
                {
                  "id": "group1",
                  "name": "Node 01",
                  "weight": "70",
                  "type": "text",
                  "node": [
                    {
                      "id": "group11",
                      "name": "Node 02",
                      "weight": "70",
                      "type": "structure",
                      "node": []
                    }
                  ]
                }
              ]
            },
            {
              "id": "id of the concept model",
              "name": "Abuse Resistent Technology",
              "type": "conceptmodel",
              "node": [
                {
                  "id": "group1",
                  "name": "Category 01",
                  "weight": "70",
                  "type": "text",
                  "node": []
                }
              ]
            },
            {
              "id": "id of the concept model",
              "name": "PC in Aviation",
              "type": "conceptmodel",
              "node": [
                {
                  "id": "group1",
                  "name": "Industry",
                  "weight": "70",
                  "type": "text",
                  "node": [
                     {
                  "id": "group1",
                  "name": "Node 01",
                  "weight": "70",
                  "type": "text",
                  "node": []
                    }
                  ]
                }
              ]
            }
          ];
    });
    li{
      list-style: none;
      background-color:#334559;
      color:#FFF;
      padding:2px;
      cursor: pointer;
      
    }
    
    
    
    
        
    
        
    

提交回复
热议问题