0

I am trying to create a div with a background of an image depending one picture.

I have tried this:

<div
  *ngIf="persona.photoURL"
  class="photo"
  style="background-image: url({{persona.photoURL}})"
></div>

but I get a div with an empty background. I know that bet.photoURL has a value. How could I achieve my goal?

1 Answer 1

4

Try with ngStyle

<div
  *ngIf="persona.photoURL"
  class="photo"
  [ngStyle]="{'background-image': 'url(' + persona.photoURL + ')'}"
></div>
Sign up to request clarification or add additional context in comments.

1 Comment

Made my day, buddy. I will mark it as correct as soon as I can

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.