【问题标题】:ngx-toastr GlobalConfig timeout settingsngx-toastr GlobalConfig 超时设置
【发布时间】:2019-05-15 08:03:32
【问题描述】:

使用 IndividualConfig 和 GlobalConfig 类无法实现。

imports: [ToastrModule.forRoot({timeOut: 10000, positionClass: 'toast-bottom-right', preventDuplicates: true})]

像上面的代码 sn-p 设置 GlobalConfig 将为所有类型的消息/toastrs 设置超时,我想控制每种类型的消息的超时。例如说我想在 2000 毫秒后超时成功消息,在 6 秒后出现错误消息,在 3 秒后发出警告和信息。我在 Growl 消息中看到了这种配置,但不确定 ngx-toastr 消息。

我尝试在 Angular 1.x 版本应用程序中使用咆哮消息

growlProvider.globalTimeToLive({ success: 2000, error: 5000, warning: 3000, info: 2000 });growlProvider.globalDisableCountDown(true);

在 Angular 6 应用程序中 imports: [ToastrModule.forRoot({timeOut: 10000})]

我可以设置适用于所有消息通知的全局超时,但我想控制每种消息类型

【问题讨论】:

标签: angularjs typescript toastr angular-toastr


【解决方案1】:

您好,您可以尝试以下配置 在你的模块中导入 ToastrModule 和 ToastContainerModule

  imports: [
    ToastrModule.forRoot({ positionClass: 'inline' }),
    ToastContainerModule,
  ]
  
  or

  imports: [
    ToastrModule.forRoot(),
    ToastContainerModule,
  ]

比调用下面的代码以超时打开烤面包机

this.toastrService.show(
  'message',
  'title',
  {positionClass:'inline',
timeOut:500000},
);

详细查看StackBlitz Code

【讨论】:

    猜你喜欢
    • 2020-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-15
    相关资源
    最近更新 更多