I've found something that looks like a bug but maybe I'm just missing something. When I use '[value]=nrSelect' it works so long as I am not using ngFor to populate the <select>. For example I put 2 dropdowns, one with ngFor and one without:
<select [value]='nrSelect' class='form-control'>
<option value='A'>A</option>
<option value='B'>B</option>
<option value='C'>C</option>
</select>
<br/>
<select [value]='nrSelect' class='form-control'>
<option *ngFor="let option of options" [value]='option.value'>{{option.label}}</option>
</select>
and in the .ts file I select option "B":
export class AppComponent {
title = 'angular-tour-of-heroes';
options = [
{ label: "A", value: "A" },
{ label: "B", value: "B" },
{ label: "C", value: "C" },
];
nrSelect = "B";
}
This produces the following when loaded:
I would have expected both to select option "B" but only the one without ngFor works. My angular version is 13.1.4. Both dropdowns work if I use [(ngModel)]=nrSelect but I'm interested in knowing why [value]=nrSelect doesn't work.
Why is that - is it a real bug or am I just not doing it correctly?
