Reputation: 1525
My form opens like so:
<form novalidate #f="ngForm" (ngSubmit)="addPage(f)">
However, after successful submission I stay on the page and then validation messages pop up even though i don't want them to, so how do I reset form after submission?
The method that submits the form goes like so:
addPage({ value, valid }) {
I tried squeezing in f
in there and then doing f.resetForm() but that didn't work out.
Upvotes: 0
Views: 2695
Reputation: 1525
There exists form
property by default on which reset()
can be called so it should be:
addPage({form, value, valid }) {
form.reset();
// rest of code
Upvotes: 0
Reputation: 3170
Try doing this (not sure where you tried to squeeze f
in),
<form novalidate #f="ngForm" (ngSubmit)="addPage(f); f.resetForm()">
See if that worked. Hope it helps.
Upvotes: 2