Angular & Signals (283 Qs)•Part 10: Reactive Forms, Standalone Components, Signals & NgRx (256 - 283)
How do you reset the form?
In a model-driven form, you can reset the form just by calling the function reset() on our form model.
For example, you can reset the form model on submission as follows,
js
onSubmit() {
if (this.myform.valid) {
console.log("Form is submitted");
// Perform business logic here
this.myform.reset();
}
}
Now, your form model resets the form back to its original pristine state.