I Have a *ngFor loop that loops through devices, the devices are connected to a real time database. My code checks to see when the device was last online and flags it as offline or online. Now for some reason "ion-select-option" is not accessible by styling it and instead gets selected in global.scss like this:
ion-alert.
select-alert {
--background: red!important;
// --color: red !important;
button {
color: white !important;
font-size: 20px !important;
}
.sc-ion-alert-md {
color: red;
}
}
This won't work as I need the colors to be dynamic. Below is a snippet of code where i attempted the change by having an array of colors levelColors
public levelColors: { [level: string]: string } = {
Alert: "grey",
online: "green",
Level2: "blue",
Level3: "orange",
offline: "red",
};
I feel the rest is self explanatory, so my question is... is there a way to color an option or should I choose a different solution?
<ion-select [(ngModel)]="vehicleSelection" (ionChange)="onSelectChange($event)">
<ion-select-option *ngFor="let vehicle of vehicleArray" [value]="vehicle"
[style.color]="levelColors[vehicle.stat]">
{{vehicle.fleet_nr}} [{{vehicle.reg_nr}}]
{{levelColors[vehicle.stat]}}
</ion-select-option>
</ion-select>