Hi All, I’m facing an interesting problem, looking for an optimal solution.
I’m getting a JSON response where I need change the text color of a particular field. The field to which I need to change the color is completely random. The number of fields are fixed, so I’m not using any *ngFor on the UI.
Ex:
Response
response = {
firstname: "name_first"
secondname: "nameSecond"
age: "34"
}
HTML part
<ion-list>
<ion-row >
<ion-col col-6> First Name</ion-col>
<ion-col col-6>{{response.firstname}}</ion-col>
</ion-row>
<ion-row >
<ion-col col-6> Last Name</ion-col>
<ion-col col-6>{{response.Lastname}}</ion-col>
</ion-row>
<ion-row >
<ion-col col-6> Age</ion-col>
<ion-col col-6>{{response.age}}</ion-col>
</ion-row>
</ion-list>
I need to change the color of any of this field depending on some condition. Ex: response.age should be of red color. I know I can keep an ID for all of these and use it to change the color. But it would not be a better approach if number of fields increases. Please let me know the best solution for this problem.