Improve this Doc View Source ngTransclude
- directive in module ng
Overview
Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.
You can specify that you want to insert a named transclusion slot, instead of the default slot, by providing the slot name as the value of the ng-transclude
or ng-transclude-slot
attribute.
If the transcluded content is not empty (i.e. contains one or more DOM nodes, including whitespace text nodes), any existing content of this element will be removed before the transcluded content is inserted. If the transcluded content is empty (or only whitespace), the existing content is left intact. This lets you provide fallback content in the case that no transcluded content is provided.
Directive Info
- This directive executes at priority level 0.
Usage
- as element:
<ng-transclude ng-transclude-slot="string"> ... </ng-transclude>
- as attribute:
<ANY ng-transclude="string"> ... </ANY>
- as CSS class:
<ANY class="ng-transclude: string;"> ... </ANY>
Arguments
Param | Type | Details |
---|---|---|
ngTransclude | ngTranscludeSlot | string | the name of the slot to insert at this point. If this is not provided, is empty or its value is the same as the name of the attribute then the default slot is used. |
Examples
Basic transclusion
This example demonstrates basic transclusion of content into a component directive.
Transclude fallback content
This example shows how to use NgTransclude
with fallback content, that is displayed if no transcluded content is provided.
Multi-slot transclusion
This example demonstrates using multi-slot transclusion in a component directive.
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.6.9/docs/api/ng/directive/ngTransclude