5 ms·
Can you include a sample of a template with your custom directive? I'm not sure what the expected thing out of the box would be. (not the code of the directiv
by hueyp 13y ago
Can you include a sample of a template with your custom directive? I'm not sure what the expected thing out of the box would be. (not the code of the directive, just the use)
- jacques_chester 13y agoHere's the original article I took inspiration from: http://sporto.github.io/blog/2013/06/24/nested-recursive-directives-in-angular/ http://sporto.github.io/blog/2013/06/24/nested-recursive-dir... I've modified it a bit to add a $watchCollection listener. So when a recursive array is updated, it deletes a child OL and then recompiles again: https://gist.github.com/jchester/6227865 https://gist.github.com/jchester/6227865 I don't particularly like the fact that this creates a dependency on jQuery (through .empty()). There are other approaches where the recursion is sorta-kinda-but-not-really built into a single directive: https://gist.github.com/furf/4331090 https://gist.github.com/furf/4331090 https://github.com/eu81273/angular.treeview https://github.com/eu81273/angular.treeview Edit: I guess what I wished for would be something like this -- <div ng-repeat="recursive items in sub_items">{{foo}}</div> or <div ng-recursive="items in sub_items">{{foo}}</div> or <div ng-repeat="items in sub_items" ng-recursive>{{foo}}</div> Whichever is easiest to get into the mainline code.
- sixbrx 13y agoThis would also be useful for me. To properly do the recursion though, I think it needs to have a function attribute "recurse-by" specified which, at any level in the structure, returns the items for the next level.