避免Angular2在按钮点击时系统地提交表单
2022-08-30 04:59:16
好吧,也许这不清楚。获取此表单:
<form (ngSubmit)="submit()" #crisisForm="ngForm">
<input type="text" name="name" [(ngModel)]="crisis.name">
<button type="submit">Submit</button>
<button type="button" (click)="preview()">Preview</button>
<button type="reset" (click)="reset()">Reset</button>
</form>
为什么所有按钮都触发了该功能?如何避免这种情况?submit()