I have n
mat-expansion-panel
in a mat-accordion
. Each panel contains a form to edit data the a certain entity. Since I use this:
<ng-template matExpansionPanelContent>
<ng-container *ngIf="ex.expanded">
</ng-container>
</ng-template>
The form and all data is discarded when closing the panel, which is intended. But I want to add a confirmation dialog if closing the panel or opening another panel in the accordion which also closes the last panel. Only on confirmation the panel should be closed. Otherwise it should stay expanded.
The dialog uses a callback like this:
this.simpleDialogService.sendMessage$({
title: 'Confirm',
message: 'Are you sure?',
buttons: [SimpleDialogButton.Yes, SimpleDialogButton.Cancel]
}).subscribe({
next: button => {
if (button === SimpleDialogButton.Yes) {
// confirm close
}
}
});