To close a nested MatDialog in Angular, you can use the MatDialogRef instance of the nested dialog and call the close() method on it.
Here is an example:
import { MatDialog } from '@angular/material/dialog';
import { NestedDialogComponent } from './nested-dialog/nested-dialog.component';
@Component({
...
})
export class ParentComponent {
constructor(private dialog: MatDialog) {}
openNestedDialog() {
const dialogRef = this.dialog.open(NestedDialogComponent);
}
}
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
...
})
export class NestedDialogComponent implements OnInit {
constructor(private dialogRef: MatDialogRef<NestedDialogComponent>) {}
ngOnInit() {}
closeNestedDialog() {
this.dialogRef.close();
}
}
<button mat-button (click)="closeNestedDialog()">Close nested dialog</button>
This will close the nested dialog and return control to the parent component.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-03 15:16:16 +0000
Seen: 10 times
Last updated: May 03 '23
What is the process for displaying my React application on the index.js file?
Is it impossible to transmit a variable from one flutter component to another?
How can a component be utilized in both React and Angular?
What is the method to bring in MouseEvent to Angular 9?
What is the process for establishing a style object to associate with a React component?
What is the method for utilizing the utils.js shared module in Bit components?
What is the process of creating a child component with Angular CLI in Angular?