Reactive form.reset()


#1

my question is if i use form.reset();
and i already have default data like this :

this.basicInformationForm = this.formBuilder.group({
         Name: ['1111'],
        Mobile: ['111111'],
        Email: ['', Validators.pattern(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i)],
        
      });

after reset the values will be null, can i return it to the default values :
example name is 1111 i change it manually in the textbox to 222, then i reset the form ,
i need it to return to 1111 not to null (or empty)


#2

If you put code on the forum, please use the < /> button to format your code in the post. Now we can’t see anything I’m afraid.


#3

see the updated code


#4

You can pass an argument to resetForm() to do this. Documented here.


#5

yes i know , but i’m wondering if there another solution, because if you do form.reset(with attribute) you have to set value to all the properties in this form , but i want to reset all the properties without one field in the form. so i used setValue(all properties - one property) ,