| 39 | |
| 40 | @NgModule({imports: [BrowserModule], declarations: [ComponentOne, ComponentTwo]}) |
| 41 | export class AppModule implements DoBootstrap { |
| 42 | // #docregion componentSelector |
| 43 | ngDoBootstrap(appRef: ApplicationRef) { |
| 44 | this.fetchDataFromApi().then((componentName: string) => { |
| 45 | if (componentName === 'ComponentOne') { |
| 46 | appRef.bootstrap(ComponentOne); |
| 47 | } else { |
| 48 | appRef.bootstrap(ComponentTwo); |
| 49 | } |
| 50 | }); |
| 51 | } |
| 52 | // #enddocregion |
| 53 | |
| 54 | fetchDataFromApi(): Promise<string> { |
| 55 | return new Promise((resolve) => { |
| 56 | setTimeout(() => { |
| 57 | resolve('ComponentTwo'); |
| 58 | }, 2000); |
| 59 | }); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | @NgModule({imports: [BrowserModule], declarations: [ComponentThree]}) |
| 64 | export class AppModuleTwo implements DoBootstrap { |
nothing calls this directly
no outgoing calls
no test coverage detected