So I have an array of items and I want to color the ion-item dynamically in the list by the value of sub.severityLevel that is within each item. The data for the items within the array come from a mysql server that I get through a rest api. I want to check the severity level of the item which can be a number between 1-5 and then based on that value set the color of the ion-item to reflect that severity level. I have tried this but it does not change the color. The value is there cause when I call it within a header it shows it but I don’t know how to get the color attribute to accept it.
<ion-content padding>
<ion-list inset>
<ion-item *ngFor="let alert of alerts">
<ion-item *ngFor="let sub of alert" (click) = "alertInfo(sub.id)" color="sub.severityLevel">
<h2>{{sub.title}}</h2>
<p>{{sub.severityLevel}}</p>
<p>{{sub.message}}</p>
<p>{{sub.description}}</p>
</ion-item>
</ion-item>
</ion-list>
</ion-content>
Phrased like that, aren’t you now setting the items color to 1, 2, 3, 4 or 5? How is that setting each items color? Just curious as to if you have more code that makes this issue solved or if you need more input.
Maybe I misunderstood and severityLevel is a string based on those numbers, which makes sense.
I set up identities for those colors in my variables.scss to represent those colors. I know those are terrible names but I was mostly just testing out how to change the items color dynamically and now I know how to do such. Those numbers each represent the severity level which is represented by a color.