Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229726

*ngIf fallback / default img src in Ionic

$
0
0

Figured it out...this is what I used in the HTML that needed the fallback image src.
The fallback img is in the API call where I checked if a certain data in the JSON was there/true.

-If it was there, pull this image
-else, pull something else

Hope this helps anyone passing by!

<ion-list *ngFor="let item of items">
    <ion-item button menuClose (click)="pushNav(item.table, item.ID)">

      <ion-thumbnail *ngIf = "item.noimg; else elseBlock" item-start>
        <img src="{{item.featured}}">
      </ion-thumbnail>

      <ng-template #elseBlock>
        <ion-thumbnail>
          <img src="{{item.pics[0]}}">
        </ion-thumbnail>
      </ng-template>
....

Viewing all articles
Browse latest Browse all 229726

Trending Articles



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