Angular reactive form is getting sumitted without submitting

I am creating one angular 5 reactive form. Everything is working fine, but I have one button to close the form, i.e to hide it from getting displayed.

When I click on that button, the form is getting submitted as if I have clicked submit button.What is the reason of this strange issue?

Even I removed the (click) event from close button, it still submit as if it is a submit button.

        <div [hidden]="add_status!='active'">

        <form novalidate (ngSubmit)="custom_submit(form.value)" 
                      [formGroup]="form">

             <button type="submit">Save</button>
             <button (click)="change_add_status()">Close</button>

             <input name="1">
             <input name="2">
             <input name="3">
             <input name="..and so on">

          </form>
           </div>

Upvotes: 2

Views: 1542

Answers (1)

Mixalloff
Mixalloff

Reputation: 837

You can try set type="button" for close button If you can't set type of button and place it inside form browser perceives it as a confirmation button

Upvotes: 4

Related Questions