Tanasos
Tanasos

Reputation: 4098

angular-cli : How to use interpolation in a property binding

How is one able to use interpolation within a two-way binding style applied?

[style.backgroundImage]="'url(' + images/{{image}} + ')'"

Where the {{image}} input interpolation spits out a lot of errors regarding expected expression and etc.

Upvotes: 2

Views: 435

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657148

[style.backgroundImage]="'url(\'images/' + image + '\')'"

You never use [prop]= together with {{}}. Either [] or `{{}}

You can also try

style.backgroundImage="'url(' + images/{{image}} + ')'"

I never tried if style bindings work without []

Upvotes: 3

Related Questions