ngrx-toastr
TypeScript icon, indicating that this package has built-in type declarations

2.2.9 • Public • Published

Toastr

Setup

step1: Add ToastrModule to app NgModule

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core';

import { ToastrModule } from './toastr/toastr.module';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    ToastrModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Use

import { ToastrService } from 'ngrx-toastr';
 
@Component({...})
export class YourComponent {
  constructor(private toastr: ToastrService) {}
 
  showSuccess() {
    this.toastr.success('Hello world!', 'heading', 'sub heading');
  }
}

Options

There are Individual Options and Global Options.

Individual Options

Individual Options

Passed to ToastrService.success/warning/error()

Option Type
message any
Heading any
SubHeading any

Global Options

Pass values to ToastrModule.forRoot()

Option Type Default
positionClass string 'toast-top-right'
timeOut number 5000
maxToastr number 5
// root app NgModule
imports: [
  ToastrModule.forRoot({
    timeOut: 5000,
    positionClass: 'toast-top-right',
    maxToast: 5
  }),
]

Package Sidebar

Install

npm i ngrx-toastr

Weekly Downloads

1

Version

2.2.9

License

ISC

Unpacked Size

87.3 kB

Total Files

25

Last publish

Collaborators

  • sahana_parameshwar