When I have a mat-select with options defined as objects in an array, I am facing an issue where the default selected value is not being set when the page renders.
In my TypeScript file, I have:
public options2 = [
{"id": 1, "name": "a"},
{"id": 2, "name": "b"}
]
public selected2 = this.options2[1].id;
In my HTML file, I have:
<div>
<mat-select
[(value)]="selected2">
<mat-option
*ngFor="let option of options2"
[value]="option.id">
{{ option.name }}
</mat-option>
</mat-select>
</div>
I've experimented with setting 'selected2' and 'value' in 'mat-option' to both the object itself and its id. Additionally, I've tried using both '[(value)]' and '[(ngModel)]' in 'mat-select', but none seem to work.
This issue arises while using material version 2.0.0-beta.10