When using Angular Elements, we'd usually have something like this to build an app as a web component:
export class AppModule implements DoBootstrap {
ngDoBootstrap(appRef: ApplicationRef): void {
customElements.define('foo', createCustomElement(AppComponent, {injector: appRef.injector}));
}
}
With the above, when a host tag is inserted in the host application, the relevant DOM fragment looks like this:
...
<foo>
#shadow-root
(AppComponent's contents)
Is there a way to inject a reference (like ElementRef
) to the <foo>
element hosting the web component into AppComponent
's constructor?