【发布时间】:2019-02-15 23:26:44
【问题描述】:
我是 ionic 新手。
我想将数据推送到我的 myForm 数组,但它显示错误 Cannot read property 'push' of undefined
这是我的表格:
public myForm: FormGroup;
constructor(){
this.myForm = this._fb.group({
docs: this._fb.array([
this._fb.group({
docName: [''],
ref_array: this._fb.array([
this._fb.group({
refTextBox: []
})
])
}),
]),
})
}
我想将元素推送到ref_array
这是我的代码:
const control2 = <FormArray>this.myForm.controls['docs']
const control3 = <FormArray>control2.controls['ref_array']
control3.push(
this._fb.group({
refTextBox: []
})
)
我在哪里犯错了? 请提前帮助和感谢!
【问题讨论】:
-
这意味着 control3 未定义。您可以记录 control3 并将输出粘贴到此处吗?
-
是的,它显示,
control3 is undefined现在我如何获得价值ref_array?
标签: angular ionic-framework ionic2 ionic3