Combine [NgStyle] With Condition (if..else)
One can also use this kind of condition:
<div [ngStyle]="myBooleanVar && {'color': 'red'}"></div>
It requires a bit less string concatenation...
Using a ternary operator inside the ngStyle
binding will function as an if/else condition.
<div [ngStyle]="{'background-image': 'url(' + value ? image : otherImage + ')'}"></div>