Ionic3 ion-img do not show images with ng-for

旧时模样 提交于 2021-01-28 06:13:26

问题


I am trying to show the dynamic images with loop using ion-img but it is not working.

<ion-item no-lines no-padding *ngFor="let company of shortedDistanceArray">
    <div>
        <ion-img style="width: 15vh;height: 12vh;" src={{company.images}}"></ion-img>
    </div>
</ion-item>

回答1:


Here you need to use property binding as shown below. Always try to avoid string interpolation.

<ion-item no-lines no-padding *ngFor="let company of shortedDistanceArray">
    <div>
        <img style="width: 15vh;height: 12vh;" [src]="company.images"></img>
    </div>
</ion-item>



回答2:


i found the solution use 'img' tag instead of 'ion-img'

<ion-item no-lines no-padding *ngFor="let company of shortedDistanceArray">
    <div>
        <img style="width: 15vh;height: 12vh;" src={{company.images}}" />
    </div>
</ion-item>


来源:https://stackoverflow.com/questions/47359153/ionic3-ion-img-do-not-show-images-with-ng-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!