Skip to content

Commit

Permalink
Add beforeClose feature to dialog demo
Browse files Browse the repository at this point in the history
  • Loading branch information
willshowell committed Aug 9, 2017
1 parent 55bdfa8 commit fdaaaad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/demo-app/dialog/dialog-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ <h2>Other options</h2>
</md-card-content>
</md-card>

<p>Last close result: {{lastCloseResult}}</p>
<p>Last afterClosed result: {{lastAfterClosedResult}}</p>
<p>Last beforeClose result: {{lastBeforeCloseResult}}</p>

<ng-template>
I'm a template dialog. I've been opened {{numTemplateOpens}} times!
Expand Down
8 changes: 6 additions & 2 deletions src/demo-app/dialog/dialog-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material';
})
export class DialogDemo {
dialogRef: MdDialogRef<JazzDialog> | null;
lastCloseResult: string;
lastAfterClosedResult: string;
lastBeforeCloseResult: string;
actionsAlignment: string;
config = {
disableClose: false,
Expand Down Expand Up @@ -51,8 +52,11 @@ export class DialogDemo {
openJazz() {
this.dialogRef = this.dialog.open(JazzDialog, this.config);

this.dialogRef.beforeClose().subscribe((result: string) => {
this.lastBeforeCloseResult = result;
});
this.dialogRef.afterClosed().subscribe((result: string) => {
this.lastCloseResult = result;
this.lastAfterClosedResult = result;
this.dialogRef = null;
});
}
Expand Down

0 comments on commit fdaaaad

Please sign in to comment.