Really hung up on this for a while.... shouldn't this work?
style="background-image:url('{{product.imageUrl}}')"
I couldn't reproduce in stack snippet, or Codepen because its angular specific.
I've tried suggestions from this thread to no avail:
https://github.com/angular/angular/issues/8745 https://github.com/angular/angular/issues/8491 https://github.com/angular/angular/issues/8514
It might be because I don't understand where I would put the 'safe' pipe in this situation. Thanks.
template context:
<div *ngIf="product.title"
class="card">
<!-- <img *ngIf="product.imageUrl"
class="card-img-top"
[src]="product.imageUrl"
alt="{{product.title}}"> -->
<div *ngIf="product.imageUrl"
class="card-img-top scale-img"
style="background-image:url('{{product.imageUrl}}')"></div>
<div class="card-body">
<h5 class="card-title">{{product.title}}</h5>
<p class="card-text">{{product.price | currency}}</p>
<div *ngIf="showActions && Cart"
class="card-footer">
<button [routerLink]="['/products/', product.$key]"
class="btn btn-details btn-secondary btn-block">Details</button>
<button *ngIf="Cart.getQuantity(product) === 0; else updateQuantity"
(click)="addToCart()"
class="btn btn-secondary btn-block">Add to Cart</button>
<ng-template #updateQuantity>
<product-quantity [product]="product"
[cart]="Cart"></product-quantity>
</ng-template>
</div>
</div>
</div>