I am currently haunting another bug as I noticed that the form I am using calls on both buttons the onSubmitClicked()
function:
Originally it looked like this:
<button mat-raised-button (click)="onBackClicked()">
Back
</button>
<button mat-raised-button type="submit">
Submit
</button>
No matter which button I am clicking, both call onSubmitClicked()
. Just the "Back" button call onBackClicked()
first. Removing the type="submit"
from the "Submit" button does not change anything.
<form [formGroup]="placeInfoForm" (ngSubmit)="onSubmitClicked()">
<div>
<mat-form-field style="width: 100%;">
<input matInput placeholder="Name" formControlName="name"/>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="center">
<button mat-raised-button (click)="onBackClicked()">
Back
</button>
<button mat-raised-button>
Submit
</button>
</div>
</form>
The submit function:
onBackClicked() {
console.log('onBackClicked()')
}
onSubmitClicked() {
console.log('onSubmitClicked()');
}