I have the following table where the ESTADO field is a drop-down list that shows the possible statuses. I want the text of the td element of the ESTADO field to display a different color when entering the screen, depending on the value it brings
I added the property [ngClass] into a option and the only thing it does is paint the text but inside the dropdown list but what I want is to show the color of the text of the td
<table class="table table-striped">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">ESTADO</th>
<th scope="col">COMENTARIO</th>
<th scope="col">HORA INICIO</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let contr of control">
<td>{{contr.id}}</td>
<td>
<select class="select" (change)="onChangeList($event, contr)">
<option value="0">{{contr.cveEstado}}</option>
<option *ngFor="let estatus of estadoModel" [value]="estatus.cveEstado" [ngClass]="{'text-red':estatus.cveEstado == 'ERR', 'text-blue':estatus.cveEstado == 'INP', 'text-orange':estatus.cveEstado== 'PDD'}">
{{estatus.descripcionEstado}}
</option>
</select>
</td>
<td>{{contr.comentario}</td>
<td>{{contr.horaInicio}}</td>
</tr>
</tbody>
</table>
I tried adding the property [ngClass] in the line
<tr *ngFor="let control of controlEjecucion" [ngClass]="{'text-red':estatus.cveEstado == 'ERR', 'text-blue':estatus.cveEstado == 'INP', 'text-orange':estatus.cveEstado== 'PDD'}">
but it does not work, it does nothing, in the same way I tried to add [ngStyle] and it does nothing
this is the css
.select-css {
background: transparent;
border: none;
font-size: 17px;
height: 30px;
padding: 5px;
width: 200px;
}
.text-red {
color:red;
}
.text-blue{
color:blue;
}
.text-orange{
color: orange;
}
.text-black{
color: black;
}
.text-green{
color: green
}
Can someone please tell me what I'm doing wrong, or how I can get the text of the td element to show color
I am not sure that ngClass works on selectbox options. Have you tried using ngStyle instead?