diff --git a/modules/angular2/src/core/life_cycle/life_cycle.ts b/modules/angular2/src/core/life_cycle/life_cycle.ts index 6b65bc07c8..9c3d4bf291 100644 --- a/modules/angular2/src/core/life_cycle/life_cycle.ts +++ b/modules/angular2/src/core/life_cycle/life_cycle.ts @@ -35,13 +35,15 @@ import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../profile/profile'; export class LifeCycle { static _tickScope: WtfScopeFn = wtfCreateScope('LifeCycle#tick()'); - _changeDetector: ChangeDetector; + _changeDetectors: ChangeDetector[]; _enforceNoNewChanges: boolean; _runningTick: boolean = false; constructor(changeDetector: ChangeDetector = null, enforceNoNewChanges: boolean = false) { - this._changeDetector = - changeDetector; // may be null when instantiated from application bootstrap + this._changeDetectors = []; + if (isPresent(changeDetector)) { + this._changeDetectors.push(changeDetector); + } this._enforceNoNewChanges = enforceNoNewChanges; } @@ -50,7 +52,7 @@ export class LifeCycle { */ registerWith(zone: NgZone, changeDetector: ChangeDetector = null) { if (isPresent(changeDetector)) { - this._changeDetector = changeDetector; + this._changeDetectors.push(changeDetector); } zone.overrideOnTurnDone(() => this.tick()); } @@ -78,9 +80,9 @@ export class LifeCycle { var s = LifeCycle._tickScope(); try { this._runningTick = true; - this._changeDetector.detectChanges(); + this._changeDetectors.forEach((detector) => detector.detectChanges()); if (this._enforceNoNewChanges) { - this._changeDetector.checkNoChanges(); + this._changeDetectors.forEach((detector) => detector.checkNoChanges()); } } finally { this._runningTick = false;