It appears that you have not implemented the FormArray
correctly, as a result you will need to implement this correctly first.
By this, I mean that you have imported the FormArray
class in your component, but are not using it as a control in your FormGroup
with controls within the array (I assume you would like to push/pop elements on this FormArray
), which is it's normal use case.
I have written an article recently on how to do this, but there is also the Angular documentation if you are having any further issues. So in this order, you will need to do the following:
- Implement the
FormArray
and FormGroup
into your form;
- If you require two-way data binding, then use
[(ngModel)]
as well as the Reactive Form binding that comes out of the box.
- In terms of your issues getting the json object out, this is a simple one; use
{{ yourForm.value | json }}
in your template, which will show your form piped into a json data structure. If there is any issue with the data, you can easily see this here as a debugging method.
The FormControl
, FormGroup
and FormArray
will output a clean and valid object, when implemented.
Send your json data to the DB.