I've come up with a code snippet below that I thought would disable the FormControl
in a FormArray
.
some.component.html
<form [formGroup]="testForm">
<div *ngFor="let num of countArr">
<input type="text" formNameArray="arrs">
</div>
</form>
some.component.ts
countArr = [1, 2, 3, 4, 5];
count = 5;
arrs;
testForm: FormGroup;
this.testForm = this.formBuilder.group(
arrs: this.formBuilder.array([])
);
this.arrs = this.testForm.get('arrs');
for (let i = 0; i < this.count; i++) {
this.arrs.insert(i, new FormControl({value: '', disabled: true}));
}
However, after running the loop, I checked the form and noticed that nothing had been disabled. Can you please point out where I might be going wrong? :-)
Your assistance is greatly appreciated!!! :-)