When I use ngClass with multiple expressions with common classes, the common class c1
is dropped when the expression changes from false to true:
<span [ngClass]="{'c1 c2' : showTwo, 'c1 c3' : showThree, 'c1 c4' : showFour}" ></span>
To overcome this I have to specify the common class using the standard class
attribute.
<span class="c1" [ngClass]="{'c2' : showTwo, 'c3' : showThree, 'c4' : showFour}" ></span>
Is there a better way of achieving this? or is it a bug with Angular2?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…