Reputation: 61
Not able to achieve using the IndividualConfig and GlobalConfig classes.
imports: [ToastrModule.forRoot({timeOut: 10000, positionClass: 'toast-bottom-right', preventDuplicates: true})]
Setting the GlobalConfig like the above code snippet will set the timeout for all the types of messages/toastrs, I would like to take control of timeout for each type of message. For example say I want to timeout success message after 2000 milliseconds, error message after 6 seconds, warn and info after 3 seconds. I see this kind of configurations available in Growl messages but not sure about ngx-toastr messages.
I have tried using growl messages in angular 1.x version application
growlProvider.globalTimeToLive({ success: 2000, error: 5000, warning: 3000, info: 2000 });growlProvider.globalDisableCountDown(true);
In Angular 6 App
imports: [ToastrModule.forRoot({timeOut: 10000})]
I am able to set global timeout which is getting applied for all message notifications but i want to take control of each message type
Upvotes: 3
Views: 7843
Reputation: 31
Hi you can try with below configuration import the ToastrModule and ToastContainerModule in your module
imports: [
ToastrModule.forRoot({ positionClass: 'inline' }),
ToastContainerModule,
]
or
imports: [
ToastrModule.forRoot(),
ToastContainerModule,
]
than call below code to open the toastr with timeout
this.toastrService.show(
'message',
'title',
{positionClass:'inline',
timeOut:500000},
);
check StackBlitz Code in detail
Upvotes: 0