Skip to content

Instantly share code, notes, and snippets.

@danielkuhlwein
Last active June 27, 2018 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkuhlwein/9ca80148f096e0e9b838b8fd0c83b522 to your computer and use it in GitHub Desktop.
Save danielkuhlwein/9ca80148f096e0e9b838b8fd0c83b522 to your computer and use it in GitHub Desktop.
Usage Example
constructor(public dialog: MatDialog) { }
openDialogSimple() {
const dialogRef = this.dialog.open(DialogComponent, {
width: '500px',
panelClass: 'ss-dialog', // always include this property of MatDialogConfig!
});
// Listen for which button was pressed and act accordingly
dialogRef.afterClosed().subscribe(result => {
if (result === 'leave') {
console.log('Yes, I am sure I want to leave the page.');
}
if (result === 'stay') {
console.log('No, I want to stay!');
}
});
}
openDialogComplex() {
const dialogRef = this.dialog.open(ComplexDialogComponent, {
width: '500px',
panelClass: 'ss-dialog', // always include this property of MatDialogConfig!
});
// Listen for which button was pressed and act accordingly
dialogRef.afterClosed().subscribe(result => {
if (result === 'Operation Cancelled') {
alert('Date selection cancelled');
} else {
alert('The date you selected was:\n' + result);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment