I have a ngClass condition like this :
<div [ngClass]="{'alert alert-danger': alert.type == 0,'alert alert-success': alert.type == 1}"
If alert.type == 1
, my class is alert alert-succes
, but if alert.type = 0
my class is alert-danger
. Why class alert
is not here ?
Yes, it seems to be an issue, but It isn't, read a comment for explanation. But you can easily have workaround by taking common class out in class
attribute itself.
<div class="alert"
[ngClass]="{'alert-danger': alert.type == 0, 'alert-success': alert.type == 1}"