这将是输出:
我不知道如何在模板中处理它
rateCardForm = this.fb.group({
package: this.fb.group({
freeDays: this.fb.array([]),
paidDays: this.fb.array([]),
}),
});
答案 0 :(得分: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],
})
)
}
要删除:
Delete(index){
var _package=<FormArray>this.rateCardForm.controls.package;
if(_package.controls.length>1){
_package.removeAt(index)
}
}