如何在表内使用表格组和表格数组同时进行迭代?我不知道如何在模板中处理它

问题描述 投票:0回答:1

这将是输出:

enter image description here

我不知道如何在模板中处理它

 rateCardForm = this.fb.group({
     package: this.fb.group({
         freeDays: this.fb.array([]),
         paidDays: this.fb.array([]),
     }),
 });
angular angular7 angular-reactive-forms
1个回答
0
投票

据我对您捕获的屏幕的了解:

rateCardForm = this.fb.group({
     package: this.fb.array([
      this.fb.group({
         freeDays: [null],
         paidDays: [null],
        })
     ]),
 });

用于将新项目添加到数组中:

Add(){
    var _package=FormArray>this.rateCardForm.controls.package;
       _package.push( 
          this.fb.group({
             freeDays: [null],
             paidDays: [null],
         })
       )
}
© www.soinside.com 2019 - 2024. All rights reserved.