Below is my code to get a response from the service. Here I am getting a list of employees.
I need to bind form controls dynamically based on the response of service, my service returning more fields(EmployeeId, Name, Department etc.) than the form has controls. How to skip those which are not used in form control?
this._employeeService.getEmployeeById(this.employeeId).subscribe((res: Response) => {
this.employeeForm.get('FileUploader').setValue(null);
for (const field in res) {
this.employeeForm.controls[field].setValue(res[field]);
}
});
this.employeeForm = this._fb.group({
EmployeeId: 0,
Name: ''
});