问题
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