fix(core): add bootstrapped modules into platform modules list (#13740)

Closes #12015

PR Close #13740
This commit is contained in:
Dzmitry Shylovich 2017-01-01 20:46:53 +03:00 committed by Miško Hevery
parent 5f40e5ba21
commit 863285a4b0
2 changed files with 7 additions and 1 deletions

View File

@ -326,7 +326,7 @@ export class PlatformRef_ extends PlatformRef {
.then((moduleFactory) => this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone)); .then((moduleFactory) => this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone));
} }
private _moduleDoBootstrap(moduleRef: NgModuleInjector<any>) { private _moduleDoBootstrap(moduleRef: NgModuleInjector<any>): void {
const appRef = moduleRef.injector.get(ApplicationRef); const appRef = moduleRef.injector.get(ApplicationRef);
if (moduleRef.bootstrapFactories.length > 0) { if (moduleRef.bootstrapFactories.length > 0) {
moduleRef.bootstrapFactories.forEach((compFactory) => appRef.bootstrap(compFactory)); moduleRef.bootstrapFactories.forEach((compFactory) => appRef.bootstrap(compFactory));
@ -337,6 +337,7 @@ export class PlatformRef_ extends PlatformRef {
`The module ${stringify(moduleRef.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` + `The module ${stringify(moduleRef.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
`Please define one of these.`); `Please define one of these.`);
} }
this._modules.push(moduleRef);
} }
} }

View File

@ -212,6 +212,11 @@ export function main() {
expect(mockConsole.res[0]).toEqual('EXCEPTION: ' + expectedErrMsg); expect(mockConsole.res[0]).toEqual('EXCEPTION: ' + expectedErrMsg);
}); });
})); }));
it('should add bootstrapped module into platform modules list', async(() => {
defaultPlatform.bootstrapModule(createModule({bootstrap: [SomeComponent]}))
.then(module => expect((<any>defaultPlatform)._modules).toContain(module));
}));
}); });
describe('bootstrapModuleFactory', () => { describe('bootstrapModuleFactory', () => {