I'm using ngForm
and ngSubmit
, and a bit confused why save()
is getting called when I click buttons that have no action associated with them. Like the Cancel button here. It shouldn't do anything, right? Here's my form.
<form #editForm="ngForm" (ngSubmit)="save()">
<div class="form-group" [ngClass]="{'has-error': url.invalid}">
<label for="url">Feed URL</label>
<input type="url" class="form-control"
id="url" name="url"
[(ngModel)]="configuration.service" #url="ngModel"
required pattern="https?://.+">
<div class="has-error text-danger" [hidden]="url.valid">
<span [hidden]="!url.errors?.required">
URL is required
</span>
<span [hidden]="!url.errors?.pattern">
URL is invalid
</span>
</div>
</div>
<button type="submit" class="btn btn-primary" [disabled]="editForm.form.invalid">
Save
</button>
<button class="btn btn-warning">
Cancel
</button>
</form>
Any ideas why cancel is calling the save
function?