refactor(core): introduce @NgModule.bootstrap and ngDoBootstrap method

If a `@NgModule` has a `bootstrap` property, `PlatformRef.bootstrapModule` /
`PlatformRef.bootstrapModuleFactory` will automatically bootstrap the components
listed in there.
If such a property does not exist, `PlatformRef.bootstrapModule` /
`PlatformRef.bootstrapModuleFactory` will try to call the method `ngDoBootstrap(appRef: ApplicationRef)` on the module class.
Otherwise an error is reported.
This commit is contained in:
Tobias Bosch
2016-08-02 06:54:08 -07:00
parent af2e80e068
commit 7e4fd7d7da
14 changed files with 156 additions and 37 deletions

View File

@ -110,7 +110,7 @@ export function serverBootstrap<T>(
providers: customProviders,
declarations: declarations,
imports: [BrowserModule],
entryComponents: [appComponentType]
bootstrap: [appComponentType]
})
class DynamicModule {
}
@ -121,6 +121,6 @@ export function serverBootstrap<T>(
const console = moduleRef.injector.get(Console);
deprecatedConfiguration.deprecationMessages.forEach((msg) => console.warn(msg));
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return appRef.bootstrap(appComponentType);
return appRef.components[0];
});
}