[英]Use Property Binding in *ngIf
I have an Array which contains the information if an Offer has an image name. 我有一个数组,其中包含要约具有图像名称的信息。 With the *ngIf
it should show either the image or "No Images". 带有*ngIf
则应显示图像或“无图像”。 But the Property Binding within *ngIf
doesn't work. 但是*ngIf
中的属性绑定不起作用。 Is this even possible? 这有可能吗?
<div class="m-c-o" *ngFor="let offer of offers">
<div class="m-c-p" *ngIf="showOffers">
<div class="m-c-img-c">
<img *ngIf="{{ offer.U_D__IMAGE }} != false" src="{{ imagePath + offer.U_D__IMAGE }}">
<div *ngIf="{{ offer.U_D__IMAGE }} === false">
<i class="materials-icons">photo_camera</i>
<div class="m-c-img-ni">No Images</div>
</div>
</div>
</div>
</div
*ngIf
directive doesn't need interpolation *ngIf
指令不需要插值
<div class="m-c-img-c">
<img *ngIf="offer.U_D__IMAGE" [src]="imagePath + offer.U_D__IMAGE">
<div *ngIf="!offer.U_D__IMAGE">
<i class="materials-icons">photo_camera</i>
<div class="m-c-img-ni">No Images</div>
</div>
</div>
You could make it more better using *ngIf else
您可以使用*ngIf else
使其变得更好
<div class="m-c-img-c">
<img *ngIf="offer.U_D__IMAGE else noResults" [src]="imagePath + offer.U_D__IMAGE" />
<ng-template #noResults>
<div>
<i class="materials-icons">photo_camera</i>
<div class="m-c-img-ni">No Images</div>
</div>
</ng-template>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.