Home > OS >  Angular Reactive Forms ngSubmit not working for single input control
Angular Reactive Forms ngSubmit not working for single input control

Time:01-23

I have a issue while using Angular reactive forms.

Please check this forked Stackblitz example from official Angular reactive forms docs, name editor form. In this example form has only one input control. I am using ngSubmit on <form> element and <button> is type="submit".

But when I submit form the page reloads. The default submit behaviour is not prevented.

CodePudding user response:

(ngSubmit) must be used with [ngForm] else the submit button will trigger the standard HMTL submit.

This means you'll have to create a FormGroup for your FormControl.

  • Related