我正在使用model driven forms并且正在寻找一种更好的方法来将数据绑定到相关的formControlName's,因为我的表单上有超过 25 个字段,我不想像我写的那样为所有字段编写代码对于下面。
模板:
<input type="text"
class="form-control"
formControlName="firstName"
name="firstName"
placeholder="First Name"
required>
组件:
this.refferalService.getReferringDataEdit(id).subscribe(
result => {
this.referringData = result.responseObject;
this.refferalForm.patchValue({
firstName: this.referringData.firstName
})
}
)
有没有办法“自动”做到这一点?