【发布时间】:2018-09-27 15:46:41
【问题描述】:
我不确定是否有人遇到过这种情况。 每当我尝试在函数中使用 ngx-spinner 时,它都不起作用。 但是当我把它放在订阅的回调中时,它就可以工作了。
在身份验证服务之外。这没有显示微调器。
login() {
this._spinner.show(); //spinner call
this._authService.login(this.user).subscribe(
data => {
sessionStorage.setItem("account", JSON.stringify(data[0].data));
sessionStorage.setItem("token", data[0].data.access_token);
setInterval(() => {
this._router.navigate(['home']);
}, 2000);
},
error => {
}
)
this._spinner.hide();
}
在身份验证服务中。这是有效的
login() {
this._authService.login(this.user).subscribe(
data => {
this._spinner.show(); //spinner call
sessionStorage.setItem("account", JSON.stringify(data[0].data));
sessionStorage.setItem("token", data[0].data.access_token);
setInterval(() => {
this._router.navigate(['home']);
}, 2000);
},
error => {
}
)
this._spinner.hide();
}
我已经导入了所有必要的库,但由于某种原因,它在 authservice 之外时无法正常工作。
【问题讨论】: