Skip to content

Commit fdaaaad

Browse files
committed
Add beforeClose feature to dialog demo
1 parent 55bdfa8 commit fdaaaad

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/demo-app/dialog/dialog-demo.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ <h2>Other options</h2>
7575
</md-card-content>
7676
</md-card>
7777

78-
<p>Last close result: {{lastCloseResult}}</p>
78+
<p>Last afterClosed result: {{lastAfterClosedResult}}</p>
79+
<p>Last beforeClose result: {{lastBeforeCloseResult}}</p>
7980

8081
<ng-template>
8182
I'm a template dialog. I've been opened {{numTemplateOpens}} times!

src/demo-app/dialog/dialog-demo.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material';
1111
})
1212
export class DialogDemo {
1313
dialogRef: MdDialogRef<JazzDialog> | null;
14-
lastCloseResult: string;
14+
lastAfterClosedResult: string;
15+
lastBeforeCloseResult: string;
1516
actionsAlignment: string;
1617
config = {
1718
disableClose: false,
@@ -51,8 +52,11 @@ export class DialogDemo {
5152
openJazz() {
5253
this.dialogRef = this.dialog.open(JazzDialog, this.config);
5354

55+
this.dialogRef.beforeClose().subscribe((result: string) => {
56+
this.lastBeforeCloseResult = result;
57+
});
5458
this.dialogRef.afterClosed().subscribe((result: string) => {
55-
this.lastCloseResult = result;
59+
this.lastAfterClosedResult = result;
5660
this.dialogRef = null;
5761
});
5862
}

0 commit comments

Comments
 (0)