Im trying to add image in my dropdown using *ngFor but Im unable to show the image icon, but can show text, Any idea how to solve this ? this is what I had tried :
html
<form [formGroup]="countryForm">
<select formControlName="countryControl" (change)="optionSelected($event.value)">
<option [value]="country" *ngFor="let country of countries"><img class="icon-custom" [src]="country.icon" [alt]="country.viewValue">{{country.viewValue}}</option></select>
</form>
ts
countries = [
{ value: 'xxx-0', viewValue: 'xxx (+xx)', code: 'xx', icon: '../../assets/svg/icon-cc-add-blue.svg' },
{ value: 'yyy-0', viewValue: 'yyy (+yy)', code: 'yy', icon: '../../assets/svg/icon-cc-add-blue.svg' }
];
optionSelected(event) {
this.selectedIcon = event.value.icon;
}
I need to solve this using typesript/angular without using any jquery plugin