I'm trying to add a formArray to my form, following this article. The error I'm getting is pasted at the bottom and seems to be an issue with [formControl]="devices.controls[i]" on the input. The error is preventing me from serving my app but I can't figure out what is wrong with it.
HTML
<div formArrayName="devices">
<h3>Devices</h3>
<button (click)="addDevice()">Add Device</button>
<div *ngFor="let control of devices.controls; index as i">
<label>
Device:
<input type="text" [formControl]="devices.controls[i]">
</label>
</div>
</div>
TS
terminalNameInput = new FormControl();
devices = new FormArray([]);
addTerminalGroup = new FormGroup({
terminalNameInput : this.terminalNameInput,
devices : this.devices,
});
addDevice() {
this.devices.push(new FormControl(''));
}
FULL ERROR
error TS2739: Type 'AbstractControl' is missing the following properties from type 'FormControl': registerOnChange, registerOnDisabledChange, _applyFormState