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'];仅用于“段落”数组。
谢谢你的帮忙!
发布于 2017-07-06 05:43:50
您可以尝试:
<FormArray>this.regulationForm.get('items.paragraphs');https://stackoverflow.com/questions/44934277
复制相似问题