ngClass not working on Ionic 4

Hi, I’m testing ngClass in a project, so that an ion-item changes color based on a numeric value, this is the HTML code

<ng-container *ngFor="let player of team1">
  <ion-item [ngClass]="{'rBG': player.Susp > 0}">
    <ion-label slot="start" (click)="presentAlert()">{{player.Name}} {{player.Surn1}} {{player.Surn2}} {{player.Num}}</ion-label>
    <ion-checkbox slot="end"></ion-checkbox>
  </ion-item>
</ng-container>

Here is my SCSS code:

.rGB{
    color: red;
 }

player.Susp holds a numeric value obtained from a database

When you inspect the Element can you confirm that the Class is not set to the Element?

Seems like it is set correctly

item rbg

item color

your Class is named rGB, but in [ngClass] you set rBG - check the typo

3 Likes

Do I feel really stupid, Thank you really for your time