O'Reilly logo

Mastering AngularJS Directives by Josh Kurz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating recursive directives

A recursive directive calls itself however many times it is needed based upon some data object. The object can be organized in any way, but most commonly it is based on a parent-child model. This means that there are nested objects within nested objects that will make up the overall structure of the finally rendered DOM.

The recursive directives are needed for various use cases. The most classic cases for a recursive directive are a drop-down menu or a nested comment directive. Any directive that builds a similar template based on a data model and has a need to call itself is a perfect candidate for a recursive directive. AngularJS makes it very simple to allow directives that call themselves. However, the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required