fix(dialog): componentInstance unavailable in afterClose (#4827)

Fixes the `dialogRef.componentInstance` being cleaned up too early, causing it to be unavailable in the `afterClosed` callback.

Fixes #4815.
This commit is contained in:
Kristiyan Kostadinov
2017-06-05 23:42:54 +02:00
committed by Andrew Seguin
parent 181820e8eb
commit cedf2197dd
2 changed files with 14 additions and 4 deletions
+2 -4
View File
@@ -27,12 +27,10 @@ export class MdDialogRef<T> {
constructor(private _overlayRef: OverlayRef, public _containerInstance: MdDialogContainer) {
_containerInstance._onAnimationStateChange
.filter((event: AnimationEvent) => event.toState === 'exit')
.subscribe(() => {
this._overlayRef.dispose();
this.componentInstance = null;
}, null, () => {
.subscribe(() => this._overlayRef.dispose(), null, () => {
this._afterClosed.next(this._result);
this._afterClosed.complete();
this.componentInstance = null;
});
}
+12
View File
@@ -367,6 +367,18 @@ describe('MdDialog', () => {
});
}));
it('should have the componentInstance available in the afterClosed callback', fakeAsync(() => {
let dialogRef = dialog.open(PizzaMsg);
dialogRef.afterClosed().subscribe(() => {
expect(dialogRef.componentInstance).toBeTruthy('Expected component instance to be defined.');
});
dialogRef.close();
tick(500);
viewContainerFixture.detectChanges();
}));
describe('passing in data', () => {
it('should be able to pass in data', () => {
let config = {