I'm following the guide on Angular Material github to set custom global configuration to use on the snackbar module. This is the guide I'm following.
However, as sais in the docs, there is no export for MAT_SNACK_BAR_DEFAULT_OPTIONS
only MAT_SNACK_BAR_DATA
but it's not overriding the default configuration.
This is what I tried:
import { MatSnackBarModule, MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
providers: [
{ provide: MAT_SNACK_BAR_DATA, useValue: { duration: 2500 } }
]
I also tried like this:
{ provide: MatSnackBarConfig, useValue: { duration: 2500 } }
{ provide: MatSnackBarConfig, useClass: SnackClass }
But none of the options is working. The snack never auto dismiss after the specified time.
import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar';
providers: [
{provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: {duration: 2500}}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With