feat(change_detection): allow triggering CD form ChangeDetectorRef

Closes #4144
This commit is contained in:
Misko Hevery 2015-09-11 14:53:49 -07:00
parent 83715f06d1
commit 63e785902f
2 changed files with 30 additions and 0 deletions

View File

@ -25,6 +25,8 @@ export class ChangeDetectorRef {
*/ */
detach(): void { this._cd.mode = ChangeDetectionStrategy.Detached; } detach(): void { this._cd.mode = ChangeDetectionStrategy.Detached; }
detectChanges(): void { this._cd.detectChanges(); }
/** /**
* Reattach the change detector to the change detector tree. * Reattach the change detector to the change detector tree.
* *

View File

@ -0,0 +1,28 @@
import {
ddescribe,
describe,
it,
iit,
xit,
expect,
beforeEach,
afterEach,
tick,
fakeAsync
} from 'angular2/test_lib';
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
import {SpyChangeDetector} from '../spies';
export function main() {
describe('ChangeDetectorRef', () => {
it('should delegate detectChanges()', () => {
var changeDetector = new SpyChangeDetector();
changeDetector.spy('detectChanges');
var changeDetectorRef = new ChangeDetectorRef(<any>changeDetector);
changeDetectorRef.detectChanges();
expect(changeDetector.spy('detectChanges')).toHaveBeenCalled();
});
});
}