Note that there are some explanatory texts on larger screens.

plurals
  1. PORecursion in Angular directives
    primarykey
    data
    text
    <p>There are a couple of popular recursive angular directive Q&amp;A's out there, which all come down to one of the following solutions:</p> <ul> <li>manually incrementally 'compile' HTML based on runtime scope state <ul> <li><a href="http://jsfiddle.net/galloc/KNM4q/1/" rel="noreferrer">example 1</a> [<a href="https://stackoverflow.com/questions/11854514/is-it-possible-to-make-a-tree-view-with-angular">stackoverflow</a>]</li> <li><a href="http://jsfiddle.net/IgorMinar/CHVbb/423/" rel="noreferrer">example 2</a> [<a href="https://github.com/angular/angular.js/wiki/JsFiddle-Examples" rel="noreferrer">angular jsfiddles page</a>]</li> </ul></li> <li>don't use a directive at all, but a &lt;script&gt; template which refers to itself <ul> <li><a href="http://jsfiddle.net/ganarajpr/vzvmS/3/" rel="noreferrer">example 1</a> [<a href="https://groups.google.com/forum/#!topic/angular/I5Z5oglW6Xw" rel="noreferrer">google groups</a>]</li> </ul></li> </ul> <p><strong>The first one</strong> has the problem that you can't remove previously compiled code unless you comprehensibly manage the manual compile process. <strong>The second approach</strong> has the problem of... not being a directive and missing out on its powerful capabilities, but more urgently, it can't be parameterised the same way a directive can be; it's simply bound to a new controller instance.</p> <p>I've been playing with manually doing an <code>angular.bootstrap</code> or <code>@compile()</code> in the link function, but that leaves me with the problem of manually keeping track of elements to remove and add.</p> <p>Is there a good way to have a parameterized recursive pattern that manages adding/removing elements to reflect runtime state? That is to say, a tree with a add/delete node button and some input field whose value is passed down a node's child nodes. Perhaps a combination of the second approach with chained scopes (but I have no idea how to do this)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload