从服务器获取userExists,因此需要提交。如果显示错误消息,并且用户在电子邮件输入字段内键入内容,则其标记为未触摸并且错误消息消失但是一旦用户将焦点移出输入字段,消息将再次显示。一旦用户输入内容直到下次提交,如何使其消失。
<form [formGroup]="resetPasswordForm" (ngSubmit)="onSubmit()">
<div *ngIf="submitted && resetPasswordForm.controls.email.touched ">
<input (input)="emailExistsHide()" formControlName="email" name="email" type="text" placeholder="Enter your Registered email id *"/>
<div *ngIf="userExists==false">User with that email does not exist</div>
</div>
<button type="submit" class="log-button log-button1">Reset Password</button>
</form>
打字稿
emailExistsHide() {
this.resetPasswordForm.controls.email.markAsUntouched();
}
你也许可以添加this.userExists=true;
inside emailExistsHide()
。由于你还没有给onSubmit()代码,所以很难判断它是否会被清除..