In my application, I have a button that triggers the opening of a component in MatDialog. This component makes API calls and is destroyed when the MatDialog is closed.
However, each time I open the MatDialog for the second time by clicking the button again, I have to redo the API calls because the first instance was destroyed.
I am searching for a solution where the initial instance of MatDialog is not destroyed, eliminating the need to make API calls every time the button is clicked.
This is an example of how my code currently looks:
this.dialogBox = this.dialog.open(FilterModal, {
data: { filters: this.dataFilters, filtersjson: this.filtersjson },
width: '300px',
height: 'calc(100vh - 120px)',
panelClass: 'custom-modalbox',
hasBackdrop: false,
position: { top: '120px', right: '0px' }
});
this.dialogBox.afterClosed().subscribe(res => {
if (res) {
// function();
} else {
// function2();
}
});