I'm using model driven forms
and I'm searching a better way to bind the data to related to formControlName
's because I have more than 25 fields on my form and I don't want to have to write that code for all fields as I have written for below.
Template:
<input type="text"
class="form-control"
formControlName="firstName"
name="firstName"
placeholder="First Name"
required>
Component:
this.refferalService.getReferringDataEdit(id).subscribe(
result => {
this.referringData = result.responseObject;
this.refferalForm.patchValue({
firstName: this.referringData.firstName
})
}
)
Is there a way to do it "automatically"?