I'm encountering an issue with the Angular Material SnackBar's onAction()
method. It seems that it is not triggering after the button is clicked. Even though I have subscribed to the onAction
, afterDismissed
, and afterOpened
methods, only the latter two are being triggered. Has anyone else faced this problem? It started occurring after updating Angular from version 9 to 11.
constructor(public snackBar: MatSnackBar) {}
private openSnackBar() {
let mySnackBar: MatSnackBarRef<TextOnlySnackBar> = this.snackBar.open('Message', 'Close');
mySnackBar.afterDismissed().subscribe((matSnackBarDismiss: MatSnackBarDismiss) => {
console.log('afterDismissed');
});
mySnackBar.onAction().subscribe(() => {
console.log('onAction');
mySnackBar.dismiss();
});
mySnackBar.afterOpened().subscribe(() => {
console.log('afterOpened');
});
}
}