With AngularJS this worked fine:
<div style="width:10px;height:10px;background-color:{{user.color}}"></div>
but with Angular5 it doesn't. How to do it with Angular5?
<div style="width:10px;height:10px;" [ngStyle]="{'background-color': user.color}">...</div>
or
<div [style.background-color]="user.color">...</div>
Docs
How to use ngStyle
<some-element [ngStyle]="{'font-style': styleExp}">...</some-element> <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element> <some-element [ngStyle]="objExp">...</some-element>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With