feat(change_detection): allow triggering CD form ChangeDetectorRef
Closes #4144
This commit is contained in:
parent
83715f06d1
commit
63e785902f
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue