-1

I have designed a special shape with html/Css and I want to receive its color from a data service.

[ngStyle]="{'background-color':'#0B0036'}"

when I use this code, everything works fine. but as soon as I try this:

[ngStyle]="{'background-color':'{{Card.lesson.color}}'}"  (with or without quote)

or

[ngStyle]="{'background-color':'Card.lesson.color'}"   

I either get errors or don't get any color at all.

what is the correct way to write that syntax?

Jota.Toledo
  • 27,293
  • 11
  • 59
  • 73
lydal
  • 802
  • 3
  • 15
  • 33

1 Answers1

1

The correct syntax is:

[ngStyle]="{'background-color': Card.lesson.color }" 

You are binding an expression into your template, not a string.

See the docs for more details

Jota.Toledo
  • 27,293
  • 11
  • 59
  • 73