I attempted to assign a value to a subgroup but encountered an error. Here is the snippet of my code:
let dataArr = new FormArray([]);
dataArr.push(new FormGroup({
'name': new FormControl(this.users[0].data[0].name),
'category': new FormControl(this.users[0].data[0].category)
}));
let formArr = <FormArray>this.myForm.controls.users;
formArr.push(this.fb.group({
name: this.users[0].name,
displayOrder: this.users[0].displayOrder,
sort: new FormGroup({
type:new FormControl(),
format: new FormControl()
}),
data: dataArr
}));
I tried to assign a value to the sort object which has type and format properties, but faced difficulties. Here is my JSON object:
[{"name":"manu","displayOrder":1,"sort":{
"type":"first","format":"normal"
},"data":[{"category":"electrical","name":"ele"}]},{"name":"divya","displayOrder":1,"data":[{"category":"tech","name":"ea_tcv"}]}]
Below is a screenshot of the form:
https://i.sstatic.net/7M8DU.png
How can I set the value for the sort object?