ngx-toastr, Toast not showing in Angular 7

后端 未结 16 1695
清歌不尽
清歌不尽 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:13

    For me, non of these solutions helped. What I did in the end was to set this in the Angular.json for the production configuration:

        "extractCss": false
    
    0 讨论(0)
  • 2021-02-01 13:15

    When I read this thread, I guess you could fix your problem. However, I would leave the solution to my problem here unless someone might have the same as us.

    What I have done to fix the problem is: to add @import '~ngx-toastr/toastr.css'; into style.css under the root directory of the project will get rid of the issue.

    0 讨论(0)
  • 2021-02-01 13:15

    In my case, It was due to a conflict between some CSS. I overwrote that CSS by simply importing the styles of ngx-toastr in styles.css

    styles.scss

    @import '~ngx-toastr/toastr.css';

    0 讨论(0)
  • 2021-02-01 13:15

    I have imported ~ngx-toastr/toastr.css in my style.css of angular app used

      @import '~ngx-toastr/toastr.css';
    
    0 讨论(0)
  • 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]
    })
    
    0 讨论(0)
  • 2021-02-01 13:18

    For Angular - Material or any angular project we SHOULD need to import modules in sequence like this in your app.module.ts:

    imports: [
     BrowserModule,
     BrowserAnimationsModule,
     ToastrModule.forRoot({
        timeOut: 3000,
        positionClass: 'toast-bottom-right',
        preventDuplicates: true,
        closeButton: true
     })
    ]
    
    0 讨论(0)
提交回复
热议问题