属性 'controls' 在类型 'AbstractControl' 上不存在
Property 'controls' does not exist on type 'AbstractControl'
我正在尝试使用此代码制作我在此站点中找到的深层嵌套反应形式: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');
尝试以这种方式访问它:['controls']
而不是 .controls
。
我遇到过一次这个错误,当我 运行 ng build --prod
const control = <FormArray>this.survey.get('sections')['controls'][j].get('questions');
我正在尝试使用此代码制作我在此站点中找到的深层嵌套反应形式: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');
尝试以这种方式访问它:['controls']
而不是 .controls
。
我遇到过一次这个错误,当我 运行 ng build --prod
const control = <FormArray>this.survey.get('sections')['controls'][j].get('questions');