In my project i'am using angular latest version, i fetch one API and i got some response, so i used *ngFor and showed the data in template(HTML) mat-dropdown in angular material. now my question is in based on API response how to show the icon in before the text?
In my API response i have the OS type, based on the OS i have to show that icons.
*ngFor condition:
<mat-option
*ngFor="let item of activeItems">
<i *ngIf="hasIcon" class="fa-{{iconType}}"></i>
<span [textContent]="item.name"></span>
</mat-option>
Icon condition:
public items: Page<PageObject>;
public iconType;
getItems() {
if(this.hasIcon == true ){
if(this.items.content.filter((item: PageObject) => item['andriod'])) {
this.iconType = 'andriod';
} else if(this.items.content.filter((item: PageObject) => item['ios'])) {
this.iconType = 'ios';
}
}
}
I tried this way but it's applying same icon for all the items. if anyone tell me how to fix this?