angular/angular.js — pull request #2670 by tilgovi (2013-05-15 23:50:06+00:00)
Title: add first pass at bare bones recursive directive

Here's a pull request to introduce a new directive, ngRecursive.

I spoke with @jbdeboer and @mhevery at last night's meetup at Google SF about it and chatting with several others validated the usefulness of such a thing. I've been using something similar in my project for about six months.

At this point it is still very early. I have not written tests yet because I would like feedback on the approach. mhevery suggested that perhaps there's a root problem that should be fixed instead: templates might notice recursive inclusions and "do the right thing". On the other hand, the approach here doesn't dictate that a recursive bit of template be in its own file, so perhaps that's nice.

Here's an example: http://plnkr.co/edit/WdnOMZ7IwbeBCFcfu7Fh

This is incredibly convenient for creating tree views of all kinds and similar recursive page structures.

One issue right now is that intervening directives cause the transclusion to break. For instance, if an ng-class is added to the ordered list element in the example above then everything breaks. I can dive into compile.js and figure out if there's a good way to address this, but again, I wanted some early feedback before I went too deep.