4

I can use ToastrService.success/error/warning/info() without problem,

but when i use ToastrService.show() i don't know which correct string type i should send

i tried send a enum like this:

export enum ToastType {
    Success = 'success',
    Error = 'error',
    Info = 'info',
    Warning = 'warning'
}

but the component lose the styles.

AndresSp
  • 176
  • 3
  • 16

2 Answers2

6

Stumbled into the same issue and found the types at the docs:

iconClasses = {
  error: 'toast-error',
  info: 'toast-info',
  success: 'toast-success',
  warning: 'toast-warning'
};

Source: https://github.com/scttcper/ngx-toastr#iconclasses-defaults

UPDATE

The show() method takes four parameters, where the type are the names listed above.

ToastrService.show(message?: string, title?: string, override?: Partial<IndividualConfig>, type?: string)

An example with all parameters can be seen here: https://stackblitz.com/edit/angular-uu7r6s

Or an even more complete example: https://github.com/grabowskidaniel/exemplo-ngx-toastr

Using NgxToastr version 10

1

I use ToasterService like this,

this._toasterService.openToast("", "update success!", "success");

this._toasterService.openToast("", "update error!", "error");
Vikki
  • 1,897
  • 1
  • 17
  • 24