You can add condition styles as below:
(1) [style] option
<div [style.color]="c1Condition ? 'red' : 'black' ">
c1 is the root
<div [style.color]="c2Condition ? 'red' : 'black' ">
c2 is inisde c1
<div [style.color]="c2Condition ? 'red' : 'black' ">
c3 is inisde c2
</div>
</div>
</div>
(2) [ngStyle] in .html file
<div [ngStyle]="currentStyles1">
Hello World
</div>
and in component.ts
this.currentStyles1 = {
'font-style': this.canSave ? 'italic' : 'normal',
'color': this.hasError ? 'red' : 'black',
'font-size': this.hasError ? '24px' : '12px'
};
(3) [ngClass] option
<div [ngClass]="false ? 'c_on' : 'c_off'">Hello world! </div>
classfor each component separately?