Angular lacks support for recursive directives #8536
Description
This is a pretty major issue in terms of being able to do things "the Angular way."
My model is a tree. Trees require recursion. I'm making an app that depends on a directive that allows movement of nodes inside a tree. In order to be able to move nodes inside this tree, I need to place "drop zones" which will detect elements that are dropped onto them.
Unfortunately, with the "Angular way" of implementing this (2 is a JSFiddle that uses similar concepts; recursive directive with transcluded template for each node of the tree) the transcluded template is rendered totally unaware of where it is located relative to where its data comes from, because the transcluded template has to be removed from its parent element before compilation.
If it's removed, it loses its scope; if it's not removed, 3 happens. (Open a console, you'll see the infinite recursion. It's the same as 2 but with the compile function commented out.) Angular tries to compile the directive while it's already compiling the directive, which fails hopelessly.
Now, there are workarounds, which is why it is possible that angular-ui-tree 4 exists. However, the only way to use it is through a recursive template (5 is a good starting point) which misses out on all the cool directive support and parametrization and is generally not the intended use of templates. The implementation here becomes hairier than it needs to be because of the lack of support for recursive directives.