2

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

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

3 Comments

[link]jsfiddle.net/eu81273/8LWUc/18 Please see this. I want to use the same script, but i need to display when i click the subUser2-1-1 is "User/subUser2-1/subUser2-1-1" instead of subUser2-1-1
Well, I showed you the direction. You need to write method that splits roleId and extract 1 2 1 1. After, you can just fetch the names and build the path.
Can you please see this Json object tree view. [link]stackoverflow.com/questions/20630281/… for this how can i extract the child depth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.