首页 > 解决方案 > 从下一页按下移动返回按钮时,取消离子页面中的 OTP 字段

问题描述

我正在使用离子手机,在手机验证和 otp 验证后,它将进入注册页面。到目前为止,它工作得很好。但是,当按下移动返回按钮时,从注册页面将进入 otp 验证页面,并自动填充 otp。从注册页面回来时,我想清除此 otp 自动填充。

这是我的代码。

<ion-content>
<form [formGroup]="verifyMobile" >
  <ion-item>
    <ion-label position="floating" >OTP (Sent to your SMS)</ion-label>
    <ion-input type="number" formControlName="otp"></ion-input>
  </ion-item>

  <p>Enter the token sent  to your mobile.</p>
  <div>
  <ion-button >Resend OTP</ion-button>
  <ion-button type="submit"  (click)="validateOTP()">Verify otp</ion-button>
  </div>
</form>

在我添加的 TS 文件中。

submit() {
   this.verifyMobile.reset()
}

但是当按下移动返回按钮时,我仍然会自动填充 OTP。

标签: formsionic-framework

解决方案


推荐阅读