[英]In Angular reactive forms can i add a nested form without an array?
this.parentForm = this._fb.group({
testControl1: [],
testControl2: [],
testChildForm1: this._fb.group({
testChildControl1: [],
testChildControl2: []
})
)};
对于上面的父窗体,它包含两个窗体控件和一个嵌套的子窗体组。
我想访问子窗体的值,如下所示
this.parentForm.controls ['testChildForm1']。controls.testChildControl1
但是由于TS给出错误,因此无法访问子窗体的控件。类型'AbstractControl'上不存在属性'controls'
这样的事情怎么样:
this.parentForm.get(`testChildForm1.testChildControl1`).value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.