I have a form in Angular 2 that works with a custom ControlGroup. At the moment, when I submit my form, I pass all the data with the following line to my controller.
Declare your form.
this.artistDetailForm= formBuilder.group({......});
Define a function to extract values on submit
// feed me controlGroups
getDirtyValues(cg) {
let dirtyValues = {}; // initialize empty object
Object.keys(cg.controls).forEach((c) => {
let currentControl = cg.find(c);
if(currentControl.dirty){
if(currentControl.controls) //check for nested controlGroups
dirtyValues[c] = getDirtyValues(currentControl); //recursion for nested controlGroups
else
dirtyValues[c] = currentControl.value; //simple control
}
});
return dirtyValues;
}
and then do this
(ngSubmit)="updateArtist(getDirtyValues( artistDetailForm ))"
PLUNKER