What happens when we use setvalue in a for loop?
Everything seems to be running smoothly, but unfortunately an error is thrown:
The property 'controls' is not recognized on the type 'AbstractControl'.
In Angular 6, how can we resolve this issue?
for (let i = 0; i < this.experience.length; i++)
{
if (i !== 0) {
const control = <FormArray>this.expGroup.controls['expArray'];
control.push(this.getExp());
}
this.expArray.at(i).controls['company_Name'].setValue(this.experience[i].company_Name);
this.expArray.at(i).controls['position'].setValue(this.experience[i].position);
this.expArray.at(i).controls['employee_id'].setValue(this.experience[i].employee_id);
this.expArray.at(i).controls['time_prefered'].setValue(this.experience[i].time_prefered);
this.expArray.at(i).controls['work_exp_year'].setValue(this.experience[i].work_exp_year);
this.expArray.at(i).controls['date_of_joining'].setValue(this.experience[i].date_of_joining);
this.expArray.at(i).controls['id'].setValue(this.experience[i].id);
}