Forms 角度:从匹配列表生成表单以保存结果

Forms 角度:从匹配列表生成表单以保存结果,forms,angular,Forms,Angular,我想用还没有结果的匹配建立一个反应式表单 团队A-团队B[输入目标A]:[输入目标B] C组-D组[输入目标C]:[输入目标D] 等等。当用户编辑一行中的两个字段时,完整结果应发送到我的数据库。我怎样才能做到这一点 我目前的状况: ngOnInit() { this.formGroup = new FormGroup({}); if (this.showResultInput && this.articles) { this.articles.forEach((

我想用还没有结果的匹配建立一个反应式表单

团队A-团队B[输入目标A]:[输入目标B]

C组-D组[输入目标C]:[输入目标D]

等等。当用户编辑一行中的两个字段时,完整结果应发送到我的数据库。我怎样才能做到这一点

我目前的状况:

ngOnInit() {
  this.formGroup = new FormGroup({});

  if (this.showResultInput && this.articles) {
    this.articles.forEach((article: IArticle) => {
      this.formGroup.addControl(article.$key  + '[homeGoals]', new FormControl());
      this.formGroup.addControl(article.$key  + '[guestGoals]', new FormControl());
  });

  this.formGroup.valueChanges.debounceTime(500).subscribe((resultArrayList: any) => {
    console.log(resultArrayList);
  });
}
和我的模板:

  <form [formGroup]="formGroup">
    <div *ngFor="let match of matches; let i = index;">
      {{match.title}}</a>
      <input type="number" [formControlName]="match.$key + '[homeGoals]'">
      <input type="number" [formControlName]="match.$key + '[guestGoals]'">
    </div
  </form>

{{match.title}