Reputation: 121
I added icon in md-option and i want to see it with the selected language. Here is my code
<md-select id="countryString" name="countryString" [(ngModel)]="selectedCountry" >
<md-option [value]="'en'">
<img src="../../assets/images/icons/en.png" />Англійська</md-option>
<md-option [value]="'ua'">
<img src="../../assets/images/icons/ukr.png" />Українська</md-option>
<md-option [value]="'ru'">
<img src="../../assets/images/icons/ru.png" />Російська</md-option>
</md-select>
I can't show img here my ask with one: https://github.com/angular/material/issues/10694
Upvotes: 0
Views: 1575
Reputation: 9116
You should create a container element with a an img
element that has a conditional src
attribute.
<!-- only show when the user has selected a value -->
<div *ngIf="selectedCountry">
<img src="../../assets/images/icons/{{selectedCountry}}.png"/>
</div>
<!-- your select element -->
<md-select ...
You might need to wrap those elements in a flex
container or using float.
Upvotes: 1