0

Trying to load image dynamically from server in div but unable to do so:

<div class="thumb" style="background-image: url('https://www.abcd.com/+ post.image)"></div>

I have already tried snippets but they don't work from this post Angular dynamic background images

gafa tufa
  • 3
  • 1
  • 5
  • If your adding from server, why are u parsing an url, it should go from assets folder on THE server or sum.. –  Nov 08 '21 at 20:29
  • Look at this solution: https://stackoverflow.com/questions/27608932/ng-style-with-interpolated-value-not-rendering-the-background-image – Vítor França Nov 08 '21 at 20:36

1 Answers1

0

if you want use dynamically. Dont use this syntactic

<div class="thumb" style="background-image: url('https://www.abcd.com/+ post.image)"></div> 

try do this

<div class="thumb" [ngStyle]="{'background-image': 'url(' + post.imageURL + ')'}" > <div>

Hope this will be helpful.

carma51
  • 16
  • 2