My expected results is to reset the form after it has been submit and set its default values binded to the formGroup control. I am attempt to reset the form to its default data after submitting by calling reset() on the form submit. Please advise me on how can I reset the default value in the date and time field .
Example :
pickupDate = new Date().toISOString().slice(0,10);
pickupTime = moment().format() ;
onSubmit(orderData: Order){
this.apiService(orderData).subscribe( order => {
orderForm.reset()
})
}
Please help Thanks
After submitting your form. you are calling
this.yourForm.reset()
Then you can patch initial values to the form like this.
this.yourForm.patchValue({
firstControllerName: this.initialValues.value1,
secondControllerName: this.initialValues.value2,
// other controller names goes here
});
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With