angular - Notify second message after first message is hidden
问题描述
I want to show wait message and after wait message is disapper then only I want to show error message or success message. At the moment the code below I tried, wait message comes and inbetween error message appears.
How can I fix this?
import { SnotifyService } from 'ng-snotify';
export class RequestResetComponent implements OnInit {
constructor(
private notify: SnotifyService,
private user: UserService
) { }
onSubmit = function () {
this.notify.info('Wait...', {timeout: 2000});
this.user.sendPasswordRestLink(this.form)
.subscribe(
res => this.handleResponse(res),
err => this.notify.error(err.error.error)
);
}
}
解决方案
使用 setTimeout 显示错误或成功消息。我在错误消息中应用了超时,请参考。
import { SnotifyService } from 'ng-snotify';
export class RequestResetComponent implements OnInit {
constructor(
private notify: SnotifyService,
private user: UserService
) { }
onSubmit = function () {
this.notify.info('Wait...', {timeout: 2000});
this.user.sendPasswordRestLink(this.form)
.subscribe(
res => this.handleResponse(res),
err => { let clearTimeOut = window.setTimeout(()=>{window.clearTimeout(clearTimeOut); this.notify.error(err.error.error)},3000);}
);
}
}
如果有任何问题,请告诉我。
推荐阅读
- javascript - 错误:无效的字符串值(arg="_name"、coderType="string"、value=null)
- operators - 不能用 'expr2'=series[bool] 调用 'operator >'。参数的类型应该是:float
- angular - 在 Angular 中,类型化的 HttpResponse 的主体可以为空。为什么?
- sql - 将 db2 数据库中的浮点值转换为日期格式?
- sql - SQL Query 以逗号分割结果并将结果作为另一个查询的输入
- c# - SingleFile 的 dotnet publish 不包含 .dylib 文件
- elasticsearch - Jaeger 与 APM 跟踪性能
- blockchain - 哪个是订阅以太坊状态变化的更有效方式
- flutter - Flutter Just Audio 背景包
- javascript - 如果未安装桌面应用程序,Viber 不会重定向到主页