Last active
August 12, 2022 18:22
-
-
Save agrgic16/9d9aa1441f6037dd4d1f2272bf03f991 to your computer and use it in GitHub Desktop.
dialog parent example from route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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
Cannot find name 'route'. Did you mean the instance member 'this.route'?