I have an Angular form which gets input from a user and converts it into a JSON object.
I need an output like this:
{"Name":"sam","age":"21","Friends":[{"Name":"bob","mobile":["123","456","789"]}]}
I need the JSON values without the key, inside another JSON list
"mobile":["123","456","789"]
I am using Reactive forms and created a nested FormArray, by doing so, I am able to get an output like this:
{"Name":"sam","age":"21","Friends":[{"Name":"bob","mobile":"123"}]}
But, how do I create another nested FormArray just with the values(without key) as mentioned above?
My component.ts
this.peopleList = this._fb.group({
Name : '',
age : '',
Friends: this._fb.array([this.CreateFriendList()])
});
CreateFriendList(): FormGroup {
return this._fb.group({
Name: '',
mobile : '',
});
}