Angular : How to check if some control exist in form or not

you can use patchValue for set value

this.employeeForm.patchValue(res);

While there already is an accepted answer, it's worth mentioning that there is indeed a method available just in case it might be useful to those actually wanting a concrete way to verify the existence of a given FormControl within a FormGroup:

contains(controlName: string): boolean


Source: https://angular.io/api/forms/FormGroup#contains


You can use the get method of FormGroup class. Change your iterator in getEmployeeById callback, like that:

for (const field in res) {
  const formControl = this.employeeForm.get(field);

  if (formControl) {
     formControl.setValue(res[field]);
  }
}

Source: https://angular.io/api/forms/FormGroup