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

Using transclusion in a directive

The following quote can be found in the documentation of transclusion (visit http://en.wikipedia.org/wiki/Transclusion):

"In computer science, transclusion is the inclusion of a document or part of a document into another document by reference."

AngularJS uses transclusion to separate DOM from its original container and place it in a new container. The separated DOM is stored in memory and wrapped in a closure function, which returns a new linking function. The returned linking function allows access to the prebound template. Optionally, the binding can be overridden by any scope passed into the function as the first parameter.

What does this mean? Any semantic markup can be yanked from the DOM and placed anywhere ...

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