0

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.

Vojislav Kovacevic
  • 1,385
  • 2
  • 17
  • 28

2 Answers2

2

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.

amal
  • 3,140
  • 1
  • 13
  • 20
0

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
Vojislav Kovacevic
  • 1,385
  • 2
  • 17
  • 28