如何用一个按钮以角提交多个表单

时间:2019-05-22 05:50:49

标签: forms submit angular7

我有2个表单,我只想通过单击一个提交按钮来提交它。这2个表单的值应该传递给服务。我该如何实现?预先感谢!

<form [formGroup]="ConvGroup">
  <div class="row">
    <div class="col-sm">
      <b style="font-weight:bolder">Comment: </b>
      <div class="form-group" *ngIf="IncidentModel.Status=='Response'">
        <textarea formControlName="ResponseDescription" class="form-control" placeholder="Write Response comment"></textarea>
      </div>
    </div>
  </div>
  <button type="submit">Submit</button>
</form>

<form #formdata="ngForm" (ngSubmit)="updateData(formdata)">
  <textarea class="form-control" name="problemDescription" readonly="readonly" [(ngModel)]="IncidentModel.ProblemDescription"></textarea>
  <input type="text" class="form-control" name="status" [(ngModel)]="IncidentModel.Status" readonly="readonly" />
</form>

这是我的打字稿代码:

constructor(private raiseTicketService: RaiseTicketService) {
}

updateData(statusform: NgForm) {
  this.raiseTicketService.postIncidentDetails(statusform.value).subscribe();
  this.raiseTicketService.postIncidentConversation(this.ConvGroup.value).subscribe();
  this.toastrService.warning('Updated Successfully');
}

0 个答案:

没有答案