diff --git a/packages/upgrade/src/dynamic/upgrade_adapter.ts b/packages/upgrade/src/dynamic/upgrade_adapter.ts index 00c52dff49..d41b49cf6b 100644 --- a/packages/upgrade/src/dynamic/upgrade_adapter.ts +++ b/packages/upgrade/src/dynamic/upgrade_adapter.ts @@ -389,8 +389,9 @@ export class UpgradeAdapter { const originalResumeBootstrap: () => void = windowAngular.resumeBootstrap; windowAngular.resumeBootstrap = function() { windowAngular.resumeBootstrap = originalResumeBootstrap; - windowAngular.resumeBootstrap.apply(this, arguments); + const r = windowAngular.resumeBootstrap.apply(this, arguments); resolve(); + return r; }; } else { resolve(); diff --git a/packages/upgrade/src/static/upgrade_module.ts b/packages/upgrade/src/static/upgrade_module.ts index e93305e0df..7eb21efa3a 100644 --- a/packages/upgrade/src/static/upgrade_module.ts +++ b/packages/upgrade/src/static/upgrade_module.ts @@ -268,7 +268,7 @@ export class UpgradeModule { windowAngular.resumeBootstrap = function() { let args = arguments; windowAngular.resumeBootstrap = originalResumeBootstrap; - ngZone.run(() => { windowAngular.resumeBootstrap.apply(this, args); }); + return ngZone.run(() => windowAngular.resumeBootstrap.apply(this, args)); }; } } diff --git a/packages/upgrade/test/dynamic/upgrade_spec.ts b/packages/upgrade/test/dynamic/upgrade_spec.ts index a3e70858f7..159f05c4ae 100644 --- a/packages/upgrade/test/dynamic/upgrade_spec.ts +++ b/packages/upgrade/test/dynamic/upgrade_spec.ts @@ -2909,6 +2909,29 @@ withEachNg1Version(() => { }, 100); })); + it('should propagate return value of resumeBootstrap', fakeAsync(() => { + @NgModule({imports: [BrowserModule]}) + class MyNg2Module { + } + + const adapter: UpgradeAdapter = new UpgradeAdapter(MyNg2Module); + const ng1Module = angular.module('ng1', []); + let a1Injector: angular.IInjectorService|undefined; + ng1Module.run([ + '$injector', function($injector: angular.IInjectorService) { a1Injector = $injector; } + ]); + + const element = html('
'); + window.name = 'NG_DEFER_BOOTSTRAP!' + window.name; + + adapter.bootstrap(element, [ng1Module.name]).ready((ref) => { ref.dispose(); }); + + tick(100); + + const value = (