I'm stuck here in a part of my job, I want the ion-card to have one color when it's odd and another when it's even. However, when the status = alert, I need it to turn red. I believe there's something wrong with the code and I'm not finding the error.
In my code I can already set the pair and odd, I just can't change the background color. Any ideas on how to solve my problem?
home.html
<ion-list>
<ion-item-sliding *ngFor="let house of houses;">
<ion-card class="cards">
<ion-card-header class="card-header">
<ion-card-title class="card-title" [ngStyle]="{'background':getColor()}"> {{ home.number}} </ion-card-title>
</ion-card-header>
</ion-card>
</ion-item-sliding>
</ion-list>
home.ts
getColor() {
var status: string;
var x;
for (x = 0; x < this.houses.length; x++) {
if ((x % 2) == 0) {
status = 'even';
} else {
status = 'odd';
}
}
switch (status) {
case 'even':
return 'Blue';
case 'odd':
return 'LightBlue';
case 'alert':
return 'Red';
}
}