2

I a have a little form in Ionic 2 and I'm getting the error ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'. when I try to disable the input.

Here is my code:

.html

<ion-card-content [formGroup]="mfaForm">    
   <ion-input formControlName="otpValue" (keyup)="onOtpChange()" type="number"></ion-input>
</ion-card-content>

.ts

ngOnInit() {
   this.buildForm();
}

onOtpChange(): void {
   const otpValue: string = this.mfaForm.get('otpValue').value;
   if (otpValue.length === OTP_CODE_MAX_LENGTH) {
      this.mfaForm.get('otpValue').disable();
   }
}

private buildForm(): void {
   this.mfaForm = this.formBuilder.group({
     otpValue: ['']
   });
}

Someone has an idea why it's happening?

Crisiiii
  • 409
  • 7
  • 22

0 Answers0