from @art-lowel: set ngModel for select, and also selected attribute for options

That currentOptionId$ observable is then used in the template to set the ngModel for the select, which, as mentioned above, should have been enough to select the correct option, but as it wasn't I also use it to set the selected attribute on the options
This commit is contained in:
L. Henze
2019-10-08 12:38:01 -04:00
parent c957031317
commit be19a2a961

View File

@@ -10,9 +10,14 @@
</div>
<div class="d-block d-sm-none">
<select name="browse-type" class="form-control" aria-label="Browse Community or Collection" (change)="onSelectChange(($event.target))">
<option *ngFor="let option of allOptions" >{{ option.label | translate }}</option>
<select name="browse-type"
class="form-control"
aria-label="Browse Community or Collection"
(ngModelChange)="onSelectChange($event)"
[ngModel]="currentOptionId$ | async">
<option *ngFor="let option of allOptions"
[ngValue]="option.id"
[attr.selected]="(currentOptionId$ | async) === option.id ? 'selected' : null">{{ option.label | translate }}</option>
</select>
</div>
</nav>