嗨,我是新来的Angular,目前我遇到了如下错误。 如果您能对此有所帮助,请多谢帮助。
GlobalSettingsComponent.html:66 ERROR Error: Cannot find control with path: 'tagonSettings -> tagonSettingFormGroup -> tagonType'
at _throwError (forms.js:2432)
at setUpControl (forms.js:2300)
at FormGroupDirective.addControl (forms.js:6664)
at FormControlName._setUpControl (forms.js:7314)
at FormControlName.ngOnChanges (forms.js:7227)
at checkAndUpdateDirectiveInline (core.js:12348)
at checkAndUpdateNodeInline (core.js:13876)
at checkAndUpdateNode (core.js:13819)
at debugCheckAndUpdateNode (core.js:14712)
at debugCheckDirectivesFn (core.js:14653)
因此,以下是我正在尝试做的事情。 我有一个表单组,并且其中包含表单数组,如下所示
this.formGroup = this.fb.group({
inventories: this.fb.array([]),
flightRates: this.fb.array([]),
settings: this.fb.array([]),
tagonSettings: this.fb.array([])
});
在tagonSettings表单数组中,我尝试如下创建并推送FormGroup的实例。 我之所以要推动一个表单组,是因为我需要对一些控件进行分组。
this.globalTagonSettingsArray.push(
new FormGroup({
id : new FormControl( globalTagonSetting.id ),
tagonText: new FormControl(globalTagonSetting.tagonText, [Validators.required] ),
tagonType: new FormControl(globalTagonSetting.tagonType, [Validators.required] )
}
)
);
在我的组件html中,我正在执行以下操作。