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:
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, NgModule, ApplicationRef} from '@angular/core';
|
||||
import {Component, NgModule} from '@angular/core';
|
||||
import {Start} from './components/start';
|
||||
import {About} from './components/about';
|
||||
import {Contact} from './components/contact';
|
||||
@ -27,13 +27,8 @@ export const ROUTES = [
|
||||
@NgModule({
|
||||
imports: [WorkerAppModule, RouterModule.forRoot(ROUTES, {useHash: true})],
|
||||
providers: [WORKER_APP_LOCATION_PROVIDERS],
|
||||
entryComponents: [App],
|
||||
bootstrap: [App],
|
||||
declarations: [App, Start, Contact, About]
|
||||
})
|
||||
export class AppModule {
|
||||
constructor(appRef: ApplicationRef) {
|
||||
appRef.waitForAsyncInitializers().then( () => {
|
||||
appRef.bootstrap(App);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user