I used AngularJs TreeView example JSFiddle
it work very well, but my problem now is when i try to read the data from a json file like the code above the tree show nothing and when i try to print data of $scope.roleList1 i found that it's empty someone know why please?
Before :
$scope.roleList1 = [
{ "roleName" : "User", "roleId" : "role1", "children" : [
{ "roleName" : "subUser1", "roleId" : "role11", "children" : [] },
{ "roleName" : "subUser2", "roleId" : "role12", "children" : [
{ "roleName" : "subUser2-1", "roleId" : "role121", "children" : [
{ "roleName" : "subUser2-1-1", "roleId" : "role1211", "children" : [] },
{ "roleName" : "subUser2-1-2", "roleId" : "role1212", "children" : [] }
]}
]}
]},
{ "roleName" : "Admin", "roleId" : "role2", "children" : [] },
{ "roleName" : "Guest", "roleId" : "role3", "children" : [] }
];
$scope.roleList = $scope.roleList1;
After :
var jsondata;
$scope.roleList1=[];
$.getJSON('data.json', function(data) {
jsondata=data;
$scope.roleList1.push(data);
});
$scope.roleList = $scope.roleList1;