Skip to content

Instantly share code, notes, and snippets.

@agrgic16
Last active August 12, 2022 18:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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);
});
}
}
@mneige
Copy link

mneige commented Aug 12, 2022

Cannot find name 'route'. Did you mean the instance member 'this.route'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment