Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dialog parent example from route
@Component({
selector: 'dialog-parent-example',
templateUrl: 'dialog-parent-example.html',
styleUrls: ['dialog-parent-example.css'],
})
export class DialogParentExample {
routeQueryParams: Subscription;
constructor(public dialog: MatDialog, private route: ActivatedRoute) {}
ngOnInit() {
this.routeQueryParams = route.queryParams.subscribe(params => {
if (params['dialog']) {
this.openDialog();
}
});
}
ngOnDestroy() {
this.routeQueryParams.unsubscribe();
}
openDialog(): void {
const dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
width: '250px',
data: {name: 'Sample Dialog'}
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed', result);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.