【发布时间】:2019-10-18 11:25:53
【问题描述】:
我无法使用 this.stockForm.reset() 清除;所以我在提交后使用它来清除数据:
clearall(): void {
this.isEditMode = false;
this.stockForm.reset({
sku: '',
productName: '',
counted: '',
});
Object.keys(this.stockForm.controls).forEach(key => {
this.stockForm.get(key).setErrors(null);
});
}
当我再次点击提交按钮时,我无法获得验证;获取默认值;所以让我知道如何在清除表单后再次验证。
【问题讨论】:
-
为什么不能在表单上使用
reset()函数? -
您应该可以使用 typescript 中提供的 this.stockForm.reset() 函数。
-
@ng-suhas 同时使用在表单字段上显示触摸错误
-
你有这方面的 stackblitz 吗?
标签: angular validation bootstrap-4 angular-reactive-forms