Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49215

How to display ion-icon based from property retrieved?

$
0
0

@dlim wrote:

Hi,

I would like to display ion-icon based from value retrieved from *ngFor.

Tried using *ngIf on ion-icon but it’s generating error.

<ion-list>
    <button ion-item (click)="getUsers()" *ngFor="let user of users" [navPush]="userPage" [navParams]="user">
      <ion-icon *ngIf="user.category=='Admin'" name="XXX" item-left></ion-icon>
      <ion-icon *ngIf="user.category=='Contributor'"  name="YYY" item-left></ion-icon>
      <h2>{{ user.first_name}}</h2>
      <p>{{ user.category}}</p>
    </button>
  </ion-list>

Here, it should display icon XXX if Category = ‘Admin’, else display icon YYY if Category=‘Contributor’

Any suggestion how to achieve this?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>