【发布时间】:2018-07-02 19:50:41
【问题描述】:
首先在使用角度。我有登录组件的问题,我想在用户输入详细信息并从服务器获得响应后显示微调器几秒钟......现在一切都发生得很快,我无法像我想要的那样在 7 秒内看到微调器to..我怎样才能延迟应用程序以便我可以看到它?这是我的代码:
组件:
showSpinner: boolean = false;
showMySpinner() {
this.showSpinner = true;
setTimeout(() => {
this.showSpinner = false;
}, 7000);
}
constructor(private dataService: DataService, private auth: AuthService,
public matService: MatService) { }
loginUser(username, password, type): void {
switch (type.value) {
case "ADMIN": {
this.dataService.getLoginResponse(username.value, password.value,
type.value).subscribe(res => {
**this.showMySpinner();** HERE I USE THE FUNCTION BUT IT GOES RIGHT UNDER IT AND DONT LET IT SHOW
this.auth.updateUserType(type.value);
sessionStorage.setItem("type", "ADMIN");
sessionStorage.setItem("username", username.value);
this.matService.openSnackBar(this.loginSuccess, "success");
}, error => this.matService.openSnackBar(this.loginFailed, "error"));
break;
}
html:
<mat-spinner [style.display]="showSpinner ? 'block' : 'none'"></mat-spinner>
谢谢
【问题讨论】:
标签: html angular angular-material spinner