3

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

Chandrababu
  • 61
  • 2
  • 9
  • I think this https://stackoverflow.com/a/45878362/6060429 answer will help you. They suggest writing a class to allow 'global' settings for each toast type – Ducker May 15 '19 at 23:25

1 Answers1

0

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

Ankit Patel
  • 31
  • 1
  • 6