我尝试使用此代码制作一个深层嵌套的反应形式,我在此网站中找到了:https://stackblitz.com/edit/deep-nested-reactive-form?file=app%2FformBuilder-way.ts
但它显示了这个错误:
Property 'controls' does not exist on type 'AbstractControl'.
此代码有什么问题?
const control = <FormArray>this.survey.get('sections').controls[j].get('questions');
const control = <FormArray>this.survey.get('sections').controls[i].get('questions').controls[j].get('options');
答案 0 :(得分:1)
尝试以这种方式访问:['controls']
而不是.controls
。
当我运行ng build --prod
const control = <FormArray>this.survey.get('sections')['controls'][j].get('questions');