How to use a templateRef with ndcDynamicContent. #507
Answered
by
gund
kotarCreative
asked this question in
Q&A
-
I am trying to use a templateRef to inject children into my ndc-dynamic component. My code looks something like this:
Any help would be appreciated 😄 |
Beta Was this translation helpful? Give feedback.
Answered by
gund
Apr 26, 2023
Replies: 1 comment 1 reply
-
I don't think you can render ng-templates directly as they are not renderable by default. <ng-template #childTpl>
... my ng-content here...
</ng-template>
<div #childContent>
<ng-container *ngTemplateOutlet="childTpl"></ng-container>
</div>
<ndc-dynamic [ndcDynamicComponent]="dynamicComponent" [ndcDynamicContent]="[[childContent.nativeElement]]"></ndc-dynamic> But I would recommend to just pass a TemplateRef as an input to a dynamic component and then render it inside of your component. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kotarCreative
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think you can render ng-templates directly as they are not renderable by default.
So you need to pre-render TemplateRef into some html node and then grab the ref to that node and pass it in as content:
But I would recommend to just pass a TemplateRef as an input to a dynamic component and then render it inside of your component.