I would like to be able to have this projected content:
<app-host>
<app-some-compA tag>...</app-some-compA>
<app-some-compB tag>...</app-some-compB>
</app-host>
And then use app-host
ViewContainerRef
to viewContainerRef.createComponent()
as many component A’s and B’s as I want. Is there an equivalent ComponentRef
to the TemplateRef
that I could use to read
in my content children query? Using template refs I could solve it like this:
class AppHostComponent {
@ContentChildren(TagDirective, {read: TemplateRef}) tagged: QueryList<TemplateRef>;
constructor(private readonly container: ViewContainerRef) {}
createNew() {
this.container.createEmbeddedView(this.tagged.get(0));
}
}
this is ofcourse just a minimal example, rough around the edges, but I’d like to do the same with components, instead of templates, but I don’t know what I could read in the content query to use?