无法使用IndividualConfig和GlobalConfig类实现。
imports: [ToastrModule.forRoot({timeOut: 10000, positionClass: 'toast-bottom-right', preventDuplicates: true})]像上面的代码片段一样设置GlobalConfig将为所有类型的消息设置超时,我想控制每种类型的消息的超时。例如,我想在2000毫秒后超时成功消息,6秒后显示错误消息,3秒后显示警告和信息。我在咆哮消息中看到了这种配置,但对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})]中
我可以设置应用于所有消息通知的全局超时,但我希望控制每种消息类型
发布于 2021-07-02 17:19:02
您好,您可以尝试使用以下配置在模块中导入ToastrModule和ToastContainerModule
imports: [
ToastrModule.forRoot({ positionClass: 'inline' }),
ToastContainerModule,
]
or
imports: [
ToastrModule.forRoot(),
ToastContainerModule,
]然后调用下面的代码来打开带有超时的toastr
this.toastrService.show(
'message',
'title',
{positionClass:'inline',
timeOut:500000},
);详细检查StackBlitz Code
https://stackoverflow.com/questions/56144336
复制相似问题