我编写了下面的代码片段,我认为它会禁用FormControl
.FormArray
some.component.html
<form [formGroup]="testForm">
<div *ngFor="let num of countArr">
<input type="text" formNameArray="arrs">
</div>
</form>
一些.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}));
}
但for
执行完成后,我检查了表单,发现没有任何内容被禁用。你能告诉我我哪里做错了吗???:-)
谢谢您的帮助!!!:-)