Question

I want to get the selected node path from root in tree view by using AngularJS. I have seen this link. It is used to get only selected node like subUser2. But i want to display selected Node path or depth like user/subUser2.

If i select subUser2 : then display User/subUser2

jsfiddle.net/eu81273/8LWUc/18/

enter image description here

Was it helpful?

Solution

If we will add to HTML: <pre>{{currentNode|json}}</pre> we can see:

{
  "roleName": "subUser2-1-1",
  "roleId": "role1211",
  "children": [],
  "selected": "selected"
}

Now the roleId is unique, in our case its role1211 where 1211 represents parent indexes:

root -> 1 -> 2 -> 1 -> 1

By this way its pretty easy to write single method that runs in loop on tree model and fetch child according to root -> 1 -> 2 -> 1 -> 1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top