I am working on a form that contains a formArray
.
InitialFrom(): void {
this.addElectricMoneyFG = this.fromBuilder.group({
hasAccountNumber: [this.showMoreInfo],
moreAccountInfo: ['', null],
description: [''],
locales: this.fromBuilder.array([]),
published: [false]
})
The formArray
structure looks like this:
selectedLanguage(langId): FormGroup {
return this.fromBuilder.group({
languageId: [langId],
name: [''],
moreAccountInfo: ['']
})
}
My goal is to disable the moreAccountInfo
field in the formArray
when a toggle is clicked.
This was my attempted code:
this.f.hasAccountNumber.valueChanges.subscribe(check => {
this.showMoreInfo = check;
if (check) {
this.f.locales['controls'][0]['controls']['moreAccountInfo'].enabled;
} else {
this.f.locales['controls'][0]['controls']['moreAccountInfo'].enabled;
}
this.f.locales.updateValueAndValidity();
this.cdRef.detectChanges()
})
However, it resulted in an error:
this.f.locales.controls[0].controls.moreAccountInfo.disabled is not a function