Reputation: 1710
I get this error after creating FormGroup.
I created a simple error template on Stackblitz.
My sample data is as follows:
Create a FormGroup as shown below:
I understand that it is not possible to create FormGroup of a string array. Because the data does not have a key value to create a name for the form group.
Is there a way to deal with this?
Upvotes: 0
Views: 420
Reputation: 27293
You can tranform arr_obj and arr_str into formArray using map operator something like this:
const formConfig = this.data.map((item)=>{
if(item.arr_obj || item.arr_str){
return {...item,arr_obj: this.fb.group(item.arr_obj),arr_str: this.fb.array(item.arr_str)}
}
return item;
});
formConfig.forEach(item => {
var temp = this.fb.group(item);
console.log(temp);
});
Upvotes: 1