【发布时间】:2019-11-27 03:02:02
【问题描述】:
如何以编程方式提交响应式表单或如何检测被点击的按钮?我有 2 个按钮来提交相同的表单,对于每个按钮单击,除了提交之外,我还想采取不同的操作。
<form (ngSubmit)="onSubmit($event)" [formGroup]="patientInfoForm">
.
.
.
<button id="add" type="submit" >Add Patient & Continue</button>
<button id="addngo" type="submit" >Add Patient</button>
</form>
【问题讨论】:
-
试试这里提到的解决方案:stackoverflow.com/questions/47408404/…
-
在这两个点击你想提交表单?
-
你为什么不使用 type="button" 和 (click)="addFunction" 和 addngoFunction?在 addFunction 和 addngoFunction 中,您可以调用 onSubmit() 并通过 this.patientInfoForm.getRawValue() 等访问表单数据...
标签: angular angular-reactive-forms