引用(https://stackoverflow.com/questions/50197347/how-to-reset-only-specific-fields-of-form-in-angular-5
) ,我有表单中有 20 个字段,如果用户单击重置选项我需要重置表单排除 2 个字段,如果我使用 this.form.reset() 意味着它重置所有内容,感谢任何帮助
最佳答案
只看onReset()
方法。此代码将重置除 name
和 description
字段之外的所有内容
formGroup: FormGroup = /* init the formGroup... */
onReset() {
this.formGroup.reset({
name: this.formGroup.get('email').value,
description: this.formGroup.get('description').value
});
}
关于angular - 重置 Angular react 形式排除特定领域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54783220/