Home:ALL Converter>How to reset Angular reactive form without clearing pre populated data?

How to reset Angular reactive form without clearing pre populated data?

Ask Time:2020-12-22T12:13:53         Author:Avocado

Json Formatter

I have a angular reactive form and some of the fields in the form are pre populated. I want to implement a 'Cancel' button that will reset all the changes to the form except the data that were pre populated when page was loaded. I tried the following but it resets the whole form:

resetForm() {
    this.myForm.reset();
  }

is there a way to reset only the current changes instead of resetting the whole form?

Author:Avocado,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/65403202/how-to-reset-angular-reactive-form-without-clearing-pre-populated-data
yy