I have a JSON and would like to output the data from this object to the FormArray. I am only getting Object object displayed in the output. What is the best way to solve this problem and what can I do better in building the code?
CodePudding user response:
FormBuilder
control
takes an object containing default value and disabled state or just the default value so update your generate form method like this:
private generateUserFormGroup(param) {
return this.fb.group({
gender: this.fb.control(param.gender),
email: this.fb.control({ value: param.email, disabled: false }),
});
}
And where your are calling this function you need to pass the currentUser
this.generateUserFormGroup(data[0].currentUser)
Check this