Angular ng-repeat and ng-if paint lines

3

Good morning community, how can I paint a certain line of a color, such as to highlight, according to the value of a field,

dato1 dato2 dato3
xx    xx    0
xx    xx    0
xx    xx    1 --> resaltar todo la fila o cambiar de color
xx    xx    0
xx    xx    1 --> resaltar todo la fila o cambiar de color


<tbody>
    <tr ng-repeat="m in MarcacionesFuncionario">
        <td>{{m.marcado}}</td>
        <td>{{m.detalleClasificadorMarcacion.descripcionDetalleClasificador}}</td>                      
       <td>{{m.detalleClasificadorMarcador.descripcionDetalleClasificador}}</td>
    </tr>
</tbody>

Best regards

    
asked by CristianBonk 25.01.2018 в 15:16
source

1 answer

4

assign a css class to the row if the data matches, for your example let's suppose as in the example that you put, that we will evaluate the attribute dato3 we use the directive NgClass

dato1 dato2 dato3
xx    xx    0
xx    xx    0
xx    xx    1 --> resaltar todo la fila o cambiar de color
xx    xx    0
xx    xx    1 --> resaltar todo la fila o cambiar de color

In the template it would be the following

<tr ng-repeat="dato in datos"  ng-class="{'resaltado': dato.dato3 == 1}">
    <td> {{ dato.dato1 }}</td>  
    <td> {{ dato.dato2 }}</td>  
    <td> {{ dato.dato3 }}</td>  
</tr>

css

.resaltado { background-color: #00FF00; }

I'll give you a complete example link

    
answered by 25.01.2018 / 15:43
source