Background:
I am trying to setup a tree view from a JSON schema - I do this using directive schema-tree
as I setup in this code. Within the view I am trying to transclude DOM elements so that this treeview can be reused. However, since there is a copy of the transcluded DOM for each endpoint, I need to determine which copy of the transcluded DOM in the recursion has been accessed.
Problem: However, my attempts at accessing the this scope have failed. The best I have come up with is to modify the scope in the compile function of the directive but this changes the transclude scope only to the value of first invocation of the directive and not recursively for every invocation.
Code:
Please find Plunker here: http://plnkr.co/edit/3wmUbMTPNuBHXYOKHsho?p=preview
In this code schema-tree
is a recursive tree in which I am trying extract path
variable for each recursion upon the button click. I can get the path
within each directive but not in the associated Transcluded DOM where I get only .root
.
Question:
What am I doing wrong? How can I access the path
of the immediate parent in the transcluded DOM.
On a related note should I use another approach to solve this problem?
Thanks in advance!!!!!!!
schemaTree
tag has apath
variable in which I store the route that has been taken to reach that particular branch - giving each branch a unique identifier. I want access thispath
in the transcluded DOM, so that any function that I included in transcluded DOM knows exactly which branch has accessed the function -> if I press a button under CORE tags, thevc.hi
function displays the path .root.core.tags in the console. Presently it'll only display .root for all which negates the purpose. – Rahul Gupta Jan 11 at 22:29ngRepeat
but this does not hold true for transclusion (Transclusion gives flexibility to make components general purpose). Transclusion will hold the scope ofviewCtrl
and notngRepeat
(this is by design in angular) - which is why I can call in the transcluded DOMvc.hi()
inspite of using isolate scope in theschema-tree
directive. As a result the transclusion scope does not know path and has to be provided this info separately. I am all ears for another solution but it must give a treeview that can include in it any arbitary function for each branch/leaf. – Rahul Gupta Jan 12 at 13:02