By default, you could close a material dialog box by clicking outside dialog box element or by pressing the esape key. However, in certain situations you may want to prevent this from happening.
Angular Material comes with a built-in property called disableClose the prevents this behavior.
- export class MyAppComponent {
- constructor(private dialog: MatDialog){}
- open() {
- this.dialog.open(ConfirmComponent, { disableClose: true });
- }
- }
- export class ConfirmComponent {
- constructor(private dialogRef: MatDialogRef<ConfirmComponent>){
- dialogRef.disableClose = true;
- }
- }

Hamid KhanPosted Mar 11, 2021, 4:36 AM
Nice blog........