<div class="bg"
onError="this.src='https://www.tibs.org.tw/images/default.jpg';"
[ngStyle]="{'background-image': 'url(' + imgss.image + ')'}"
*ngFor="let imgss of prod.product_images | slice:0:1;">
</div>
how to get alternate image if there is no image on it, i have tried using onError but which works only on image tag,but here am using only div.
<div class="bg" [ngStyle]="{'background-image': (imgss.image) ? 'url(' + imgss.image + ')' : 'url(https://www.tibs.org.tw/images/default.jpg)' }"
*ngFor="let imgss of prod.product_images | slice:0:1;"></div>
Hope this will help you!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.