user8516249
user8516249

Reputation:

Angular: How to data-bind an async property to a background image

The question is: How do I modify my below snippet to work? :)

HTML

 <div [ngStyle]="{'background-image': 'url(' + image.imageurl | async  + ')'}">

Error

Parser Error: Missing expected }

I'm not entirely sure where that's supposed to go.

Thank you.

Upvotes: 6

Views: 6947

Answers (1)

Jaroslaw K.
Jaroslaw K.

Reputation: 5374

Adding brackets will be helped, because you are trying call async pipe on 'url(' + image.imageurl

Try in this way:

<div [ngStyle]="{'background-image': 'url(' + (image.imageurl | async)  + ')'}">

Upvotes: 10

Related Questions