Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to use recursive function to select the parent in a tree array using angulat ui tree


function buildTree() {
    TreeService.getTree().then(function (result) {
        tc.tree = result.data;
        
        function setParentForChildren(n) {
            angular.forEach(n.children, function (c) {
                c.parent = n;
                setParentForChildren(c);
            })
        }
        angular.forEach(tc.tree, setParentForChildren);
    }, function (result) {
        alert("Tree no available, Error: " + result);
    });
}
 
PREVIOUS NEXT
Tagged: #recursive #function #select #parent #tree #array #angulat #ui #tree
ADD COMMENT
Topic
Name
5+6 =