Learning Learning - 24 days ago 9
AngularJS Question

How to store reference of all parents for each of the nested child?

Fiddle : http://jsfiddle.net/p35cobgx/3/

Below is my tree structure :

Node
Node-1
Node-1-1......


Now I want to store back reference of all parents for each of the nodes like below :


Node

Node-1 (should store back reference of only Node because this is
last parent for Node-1)

Node-1-1(should store back reference of all parents i.e Node-1 and
Node because Node is the last parent for Node-1-1).


But problem with my code is i am unable to store reference of Node for Node-1-1.

enter image description here

Answer Source

Use this condition for assigning the parent:

obj.parent = data.parent || null;