Skip to content

Instantly share code, notes, and snippets.

@agrgic16
Last active August 12, 2022 18:22
Show Gist options
  • Save agrgic16/9d9aa1441f6037dd4d1f2272bf03f991 to your computer and use it in GitHub Desktop.
Save agrgic16/9d9aa1441f6037dd4d1f2272bf03f991 to your computer and use it in GitHub Desktop.
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