Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bisubus/fbef01fdb3b14e7349aead9b00701260 to your computer and use it in GitHub Desktop.
Save bisubus/fbef01fdb3b14e7349aead9b00701260 to your computer and use it in GitHub Desktop.
import { Inject, Type, ApplicationRef, ComponentFactoryResolver } from '@angular/core';
import { DOCUMENT } from '@angular/common';
@NgModule({
imports: [BrowserModule],
declarations: [App, Bpp],
entryComponents: [App, Bpp]
})
export class AppModule {
static bootstrapComponents: Type[] = [App, Bpp];
constructor(
@Inject(DOCUMENT) private _document: any,
private _componentFactoryResolver: ComponentFactoryResolver
) {}
ngDoBootstrap(applicationRef: ApplicationRef) {
for (const component of AppModule.bootstrapComponents) {
const { selector } = this._componentFactoryResolver.resolveComponentFactory(component);
if (this._document.querySelector(selector)) {
applicationRef.bootstrap(component);
}
}
}
}
@glenatron
Copy link

This was very useful but things have changed a little in Angular 8 - I got it working as described in the answer to this SO question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment