2

I have checked this post AngularJS - Json to Tree structure but their code is bit difficult to understand.

Basically I want to generate tree from my json.....does any easy way exist?

Here is my json:

angular.module("myApp", []).
controller("MasterDetails", ['$scope', function($scope) {
    $scope.details = [{"ID":1,"Name":"Suzy","ParentID":0},
{"ID":2,"Name":"Somi","ParentID":1},
{"ID":3,"Name":"Romi","ParentID":2},
{"ID":4,"Name":"Jumi","ParentID":3},
{"ID":5,"Name":"Gargi","ParentID":0},
{"ID":6,"Name":"Sujoy","ParentID":5},
{"ID":7,"Name":"Kamal","ParentID":6},
{"ID":8,"Name":"Joy","ParentID":0},
{"ID":9,"Name":"Sumana","ParentID":8},
{"ID":10,"Name":"Alex","ParentID":0}];
}]);

Looking for guidance. Thanks.

Mirza Sisic
  • 2,401
  • 4
  • 24
  • 38
Monojit Sarkar
  • 2,353
  • 8
  • 43
  • 94
  • I have done something similar using a combination of `angular.js` and the `vis.js` library. Basically you just need to handle the basic data structure operations; insert, update, delete. You can see it here: https://github.com/Parasin/MEAN-Decision-Tree/blob/master/mean-auth/client/partials/admin.html – Evan Bechtol May 18 '16 at 12:35
  • It's not a tree, it's a forest =) You should rebuild this to hierarchy for start. Then you can to use template recursion for represent it in view. – vp_arth May 18 '16 at 12:48

0 Answers0