diff --git a/modules/@angular/examples/upgrade/static/ts/module.ts b/modules/@angular/examples/upgrade/static/ts/module.ts index 20dd59871ee34c..685e6d9931f917 100644 --- a/modules/@angular/examples/upgrade/static/ts/module.ts +++ b/modules/@angular/examples/upgrade/static/ts/module.ts @@ -8,6 +8,7 @@ import {Component, Directive, DoCheck, ElementRef, EventEmitter, Inject, Injectable, Injector, Input, NgModule, OnChanges, OnDestroy, OnInit, Output, SimpleChanges} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; +import * as angular from '@angular/upgrade/src/angular_js'; import {UpgradeComponent, UpgradeModule, downgradeComponent, downgradeInjectable} from '@angular/upgrade/static'; interface Hero { diff --git a/modules/@angular/upgrade/src/aot/upgrade_module.ts b/modules/@angular/upgrade/src/aot/upgrade_module.ts index 46cef6c605b045..f7f6814f769e67 100644 --- a/modules/@angular/upgrade/src/aot/upgrade_module.ts +++ b/modules/@angular/upgrade/src/aot/upgrade_module.ts @@ -166,16 +166,14 @@ export class UpgradeModule { (testabilityDelegate: angular.ITestabilityService) => { const originalWhenStable: Function = testabilityDelegate.whenStable; const injector = this.injector; - // Cannot use arrow function below because we need to grab the context + // Cannot use arrow function below because we need the context const newWhenStable = function(callback: Function) { - const whenStableContext: any = this; originalWhenStable.call(this, function() { const ng2Testability: Testability = injector.get(Testability); if (ng2Testability.isStable()) { callback.apply(this, arguments); } else { - ng2Testability.whenStable( - newWhenStable.bind(whenStableContext, callback)); + ng2Testability.whenStable(newWhenStable.bind(this, callback)); } }); }; diff --git a/modules/@angular/upgrade/src/upgrade_adapter.ts b/modules/@angular/upgrade/src/upgrade_adapter.ts index e1984eaad0a4e0..a488d9ca285888 100644 --- a/modules/@angular/upgrade/src/upgrade_adapter.ts +++ b/modules/@angular/upgrade/src/upgrade_adapter.ts @@ -355,14 +355,14 @@ export class UpgradeAdapter { function(testabilityDelegate: angular.ITestabilityService) { const originalWhenStable: Function = testabilityDelegate.whenStable; - const newWhenStable = (callback: Function): void => { - const whenStableContext: any = this; + // Cannot use arrow function below because we need the context + const newWhenStable = function(callback: Function) { originalWhenStable.call(this, function() { const ng2Testability: Testability = moduleRef.injector.get(Testability); if (ng2Testability.isStable()) { callback.apply(this, arguments); } else { - ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback)); + ng2Testability.whenStable(newWhenStable.bind(this, callback)); } }); }; @@ -433,8 +433,9 @@ export class UpgradeAdapter { if (windowAngular.resumeBootstrap) { const originalResumeBootstrap: () => void = windowAngular.resumeBootstrap; windowAngular.resumeBootstrap = function() { + let args = arguments; windowAngular.resumeBootstrap = originalResumeBootstrap; - windowAngular.resumeBootstrap.apply(this, arguments); + ngZone.run(() => { windowAngular.resumeBootstrap.apply(this, args); }); resolve(); }; } else {