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?
Try with ngStyle
<div
*ngIf="persona.photoURL"
class="photo"
[ngStyle]="{'background-image': 'url(' + persona.photoURL + ')'}"
></div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.