Transcluding Elements

Transcluding can be kind of a difficult concept to pick up on at first. Basically, the idea is that you can keep the contents of the custom directive defined in an AngularJS template and bind them to the scope. The way this works is that the linking function for the directive receives a transclusion function that is prebound to the current scope. Then elements inside the directive have access to the scope outside the directive.

You can set the transclude option to the following values:

true: Transcludes the content of the directive.

'element': Transcludes the whole element, including any directives defined at lower priorities.

You must also include the ngTransclude directive in elements inside your directive template. ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.