Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngx-toastr ToastrService.show() type parameter Angular 2 +

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.

like image 558
AndresSp Avatar asked Sep 11 '25 01:09

AndresSp


1 Answers

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

like image 152
Daniel Grabowski Avatar answered Sep 13 '25 15:09

Daniel Grabowski