angular - 获取错误“检查后表达式已更改”禁用离子项
问题描述
我在 Ionic 2 中有一个小表单,ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
当我尝试禁用输入时出现错误。
这是我的代码:
.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: ['']
});
}
有人知道为什么会这样吗?
解决方案
推荐阅读
- r - 如何在 R 命令中使用迭代变量?
- javascript - 如何更改 vue-apexcharts 中的特定线条颜色,如 contidional 颜色更改?
- java - 如何覆盖 Kotlin 对象中的函数?
- python - 在 Open Cascade 中修改几何图形时,如何保留 STEP 文件中的颜色?
- amazon-web-services - AWS ECS 任务日志
- microsoft-graph-api - 图形 API 搜索缺少的扩展
- r - 一组一组的总和:group_by 总结
- android -
- c# - 如何将实现从单一行为中抽象出来?
- javascript - 捆绑一个小任务以使 puppeteer 中的所有依赖项都可用?