fix(upgrade/static): ensure upgraded injector is initialized early enough (#14065)

This change ensures that the upgraded AngularJS injector is initialized
before the application run blocks are executed.

Closes #13811
This commit is contained in:
Pete Bacon Darwin
2017-01-24 22:48:03 +00:00
committed by Alex Rickabaugh
parent bd2eecb4de
commit 3b2fb23805
2 changed files with 30 additions and 3 deletions

View File

@ -150,10 +150,12 @@ export class UpgradeModule {
*/
bootstrap(
element: Element, modules: string[] = [], config?: any /*angular.IAngularBootstrapConfig*/) {
const INIT_MODULE_NAME = UPGRADE_MODULE_NAME + '.init';
// Create an ng1 module to bootstrap
const upgradeModule =
const initModule =
angular
.module(UPGRADE_MODULE_NAME, modules)
.module(INIT_MODULE_NAME, [])
.value(INJECTOR_KEY, this.injector)
@ -205,6 +207,8 @@ export class UpgradeModule {
}
]);
const upgradeModule = angular.module(UPGRADE_MODULE_NAME, [INIT_MODULE_NAME].concat(modules));
// Make sure resumeBootstrap() only exists if the current bootstrap is deferred
const windowAngular = (window as any /** TODO #???? */)['angular'];
windowAngular.resumeBootstrap = undefined;