I am trying to patch value an array of ids from Firestore into a mat-select with multiple options. I am looping through the array and creating a new form control for each id and then using the reactive form push method to add to the formArray. Like so:
patchValueForm(portfolio: any) {
this.formGroup.patchValue(portfolio);
for (const id of portfolio.property_ids) {
const control = new FormControl(id);
if (!this.property_ids.getRawValue().includes(id)) {
this.property_ids.push(control);
}
}
console.log(this.formGroup.getRawValue()); }
This does seem to patch the value into the form as shown from the console log:
The problem that I am having is that its then not pre populating the material select shown here:
The HTML that I am using for this part is:
<mat-form-field appearance="outline">
<mat-select [formArrayName]="'property_ids'" multiple>
<mat-option *ngFor="let property of properties; let i = index"
(onSelectionChange)="updatePropertyIdArray(property.property_id)" >
{{property?.address?.first_line_address}}
</mat-option>
</mat-select>
<mat-error>Please select at least one property</mat-error>
</mat-form-field>
I have searched everywhere online and tried multiple different methods, but still ca not seem to populate the select. Has anyone experienced this before?

