我有“onSubmit”方法,它根据服务器响应从服务器和触发动画的方法返回响应。问题是来自“hideElementAnimation”的“this.serverRespond”没有根据来自“onSubmit”方法的this.serverRespond更新值。
serverRespond: boolean = false;
动画功能触发提交按钮单击
hideElementAnimation() {
if(this.serverRespond) {
this.state = (this.state === 'inactive' ? 'active' : 'inactive');
setTimeout(() => {
this.animationDoneResult = false;
},300);
}
}
onSubmit fire on form submit并传递来自输入的电话号码
onSubmit(input_value): void {
this.smssend = this.service.smsSendRequest(user_phone)
.subscribe( data => {
this.serverRespond = data;
});
}
形式
<form (ngSubmit)="onSubmit(inputPhone.value)"
*ngIf="animationDoneResult">
<div class="input-holder">
<input #inputPhone>
<button type="submit"
(click)="hideElementAnimation()">
</button>
</div>
</form>