export class RegulationComponent implements OnInit {
regulation: Regulation;
isCreateNew = false;
regulationForm: FormGroup;
itemArray: FormArray;
paragraphArray: FormArray;
constructor(private route: ActivatedRoute, private fb: FormBuilder) {
this.regulationForm = new FormGroup({
head: new FormControl(''),
title: new FormControl(''),
info: new FormControl(''),
createdDate: new FormControl(''),
tableOfContentTitle: new FormControl(''),
items: new FormArray([
new FormGroup({
number: new FormControl(''),
text: new FormControl(''),
title: new FormControl(''),
paragraphs: new FormArray([
new FormGroup({
number: new FormControl(''),
text: new FormControl(''),
title: new FormControl('')
})
])
})
]),
});
this.itemArray = <FormArray>this.regulationForm.controls['items'];
}
这是我的表格,我的问题是:如何访问“items”数组中的“paragraph”数组?
像
这样的东西this.itemArray = <FormArray>this.regulationForm.controls['items'];
仅适用于“paragraph”数组。
感谢您的帮助!
答案 0 :(得分:0)
你可以尝试:
<FormArray>this.regulationForm.get('items.paragraphs');