I need a div to have a css-class when a variable cfgSelected
is has a certain value .. here '1' (<- string!!)
<div [ngClass]="(cfgSelected ==='1')?'isActive':'isNormal'"
(click)="selectThisOne('1')">
bla ...
</div>
in the ts-file:
selectThisOne(id: any) {
this.cfgSelected = id;
}
it works in --dev but when I want to build --prod it I get
ERROR in src\app\configurator\configurator.component.html(80,50): : Operator '===' cannot be applied to types 'number' and 'string'.
can someone please tell me what is wrong with that?
===
operator doesn't cast the arguments to the same type, but if you used==
it could work (but not best practice) – itsmewiththeface