I have created a function that shows the message using material snackbar.
showMessage(message: string, position = { horizontal: "right", vertical: "bottom" }): void {
const _htmlMessage ="some message";
this.snackBar.openFromComponent(SnackbarComponent, {
data: {
html: _htmlMessage
},
duration: 2000,
horizontalPosition: position.horizontal,
verticalPosition: position.vertical
});
}
but this shows:
Type 'string' is not assignable to type 'MatSnackBarHorizontalPosition'.ts(2322)
snack-bar-config.d.ts(42, 5): The expected type comes from property 'horizontalPosition' which is declared here on type 'MatSnackBarConfig'
but if I directly assign the value like this:
duration: 2000,
horizontalPosition: "right",
verticalPosition: "bottom"
this works. How can I solve this?