[英]how to disable one of control item of form array in angular 9
I have a form and in this form in this form I have a formArray
.我有一个表格,在这个表格中我有一个formArray
。
InitialFrom(): void {
this.addElectricMoneyFG = this.fromBuilder.group({
hasAccountNumber: [this.showMoreInfo],
moreAccountInfo: ['', null],
description: [''],
locales: this.fromBuilder.array([]),
published: [false]
})
the formArray
: formArray
:
selectedLanguage(langId): FormGroup {
return this.fromBuilder.group({
languageId: [langId],
name: [''],
moreAccountInfo: ['']
})
} }
When clicking on the toggle I want, moreAccountInfo
in the formArray
to be disabled
.单击我想要的切换时, moreAccountInfo
中的formArray
将被disabled
。
I wrote this 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()
})
It didn't work, threw this error:它没有用,抛出这个错误:
this.f.locales.controls[0].controls.moreAccountInfo.disabled is not a function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.