Angular 2 reset form to initial data without having to set each formcontrol individually

Viewed 5128

I have a formGroup which I open in edit mode and initialize with the proper data. I also save this initial data in editForm.

After doing changes to it I want to reset all the changes to the initial values, something like:

this.formGroup.reset(this.staffToEdit);

But all this does is put blank in every field. The only workaround I found is to do something like

this.formGroup.reset({field1 : this.editForm.field1});
...

The thing is I need something more generic that resets all the fields to their initial value without having to go through each formControl.

Is this possible to do?

2 Answers
Related