Last active
November 14, 2019 12:26
-
-
Save bisubus/fbef01fdb3b14e7349aead9b00701260 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.