diff --git a/src/demo-app/dialog/dialog-demo.ts b/src/demo-app/dialog/dialog-demo.ts index bead8535b659..5e91c097f9aa 100644 --- a/src/demo-app/dialog/dialog-demo.ts +++ b/src/demo-app/dialog/dialog-demo.ts @@ -1,5 +1,5 @@ -import { Component, Inject } from '@angular/core'; -import { DOCUMENT } from '@angular/platform-browser'; +import {Component, Inject} from '@angular/core'; +import {DOCUMENT} from '@angular/platform-browser'; import {MdDialog, MdDialogRef, MdDialogConfig} from '@angular/material'; @Component({ diff --git a/src/lib/dialog/dialog.ts b/src/lib/dialog/dialog.ts index 2f94fb531bed..57f65bdc8277 100644 --- a/src/lib/dialog/dialog.ts +++ b/src/lib/dialog/dialog.ts @@ -22,6 +22,8 @@ import {MdDialogContainer} from './dialog-container'; @Injectable() export class MdDialog { private _openDialogsAtThisLevel: MdDialogRef[] = []; + private _afterAllClosedAtThisLevel = new Subject(); + private _afterOpenAtThisLevel = new Subject>(); /** Keeps track of the currently-open dialogs. */ get _openDialogs(): MdDialogRef[] { @@ -29,10 +31,13 @@ export class MdDialog { } /** Subject for notifying the user that all open dialogs have finished closing. */ - private _afterAllClosed = new Subject(); - + get _afterOpen(): Subject> { + return this._parentDialog ? this._parentDialog._afterOpen : this._afterOpenAtThisLevel; + } /** Subject for notifying the user that a dialog has opened. */ - private _afterOpen = new Subject>(); + get _afterAllClosed(): Subject { + return this._parentDialog ? this._parentDialog._afterAllClosed : this._afterAllClosedAtThisLevel; + } /** Gets an observable that is notified when a dialog has been opened. */ afterOpen: Observable> = this._afterOpen.asObservable();