Is there a way to retrieve the value from mat-autocomplete when using formControlName? It seems that mat-autocomplete doesn't work in this scenario.
<mat-form-field>
<mat-label>...</mat-label>
<input type="text" matInput aria-label="..."
//[formControl]="attributeListCtrl"
formControlName="attributeKey"
[matAutocomplete]="auto" [readonly]="VOForm.get('VORows').value[i].isEditable">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn" (optionSelected)="onDBAttrSelected()">
<mat-option *ngFor="let option of attributeList" [value]="option">
{{option.nameAttribute}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
I have come across suggestions to use
[formControl]= form.get('attributeKey')
, but it's not effective in my case due to the nested array with groups in my formBuilder.
this.VOForm = this.fb.group({
VORows: this.fb.array(this.attributeList.map((val:any) => this.fb.group({
idx: new FormControl('1'),
attributeKey: new FormControl<string | Attribute>(''),
attributeValue: new FormControl(val.attribute.allValue),
action: new FormControl('existingRecord'),
isEditable: new FormControl(true),
isNewRow: new FormControl(false),
})
)) //end of fb array
});