ngx-toastr, Toast not showing in Angular 7

后端 未结 16 1921
清歌不尽
清歌不尽 2021-02-01 12:37

I\'m currently developing a web app using Angular 7. I wanted to include ngx-toastr to send notifications to users but it isn\'t working as expected. When I trigger a toast noth

16条回答
  •  青春惊慌失措
    2021-02-01 13:17

    you need to import

    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    

    and add that under the @NgModule imports

    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    @NgModule({
      declarations: [
       ......
      ],
      imports: [
         ......
        BrowserAnimationsModule,
        ToastrModule.forRoot({ timeOut: 2000 enableHtml: true }),
      ],
      providers: [
        ToastService,
         ......
      ],
      bootstrap: [AppComponent]
    })
    

提交回复
热议问题