【发布时间】:2020-11-07 17:35:29
【问题描述】:
以下是我的注销电话:
logoutClick() {
let response: any;
this._httpService.fetch(SERVICE_URL.LOGOUT, 'get').subscribe(
(res: any) => {
response = res;
},
(error: any) => {
this._commonService.showLoader = false;
this._cookieService.delete('tokenId');
this._cookieService.delete('userInfo');
},
() => {
debugger;
console.log('abgffgdfgdg');
this._cookieService.delete('tokenId');
this._cookieService.delete('userInfo');
this._commonService.showLoader = false;
},
);
}
这需要在浏览器关闭时调用,
在下面尝试过:
window.addEventListener('beforeunload', function (e) {
e.preventDefault();
this.onLogoutClick()
});
没有按预期工作, 使用角度版本 7
【问题讨论】:
-
1)
that.onLogoutClick()错字:that.->this.2) 如果“完成”,订阅中的第三个参数将运行。
标签: angular asynchronous browser rxjs angular7