I have an object of values in angular and I want to add that object to my formGroup. But somehow I am unable to do that. Please check my code and let me know where I am wrong.
ngOnInit() {
this.socialMediaForm = this.fb.group({
//---------------------//
// Add values here //
//-------------------//
socialAccounts: this.fb.array([]),
});
const userInfo = JSON.parse(localStorage.getItem('user_info'));
for (const [key, value] of Object.entries(userInfo)) {
this.socialMediaForm.patchValue({ [key]: value });
}
}
Any solution appreciated!