I have an issue with angular material snackbar. It works on localhost, but after build process I got an error:
Cannot read properties of undefined (reading 'openSnackBar')
I call a commonservce that provides snackbar func, from other service file.
call:
private async handle() {
this.commonService.openSnackBar('test snackbar');
...
commonService:
public openSnackBar(message: string, icon?: string) {
return this.zone.run(() => {
// this.snackbar.open(message, 'x', config);
this._snackBar.open(message, icon, { horizontalPosition: this.horizontalPosition, verticalPosition: this.verticalPosition, duration: 3000 });
});
}
ps zoge was added, but nothing changed. still works on localhost but not after build process.
I resolved the issue. Method call was executed from constructor. Solution was inject dependant service to calling method inside constructor as method
paramand remove "this" from call method body.execute: