Reputation: 414
I am working on Angular4 project and am using ngx-datatable so .html file looks like
<ngx-datatable>
<ngx-datatable-column>
<ng-template> ...
{{row.value}}
What I want to achieve is to check for value, whether with *ngIf
or inside typescript for value, and if value > 100 set ROW background to red, else it should be white as it is.
How to achieve that? Thanks for help
Upvotes: 1
Views: 5212
Reputation: 584
Add this to the row..
[style.background-color]='row.value >= 100 ? "red":"" '
Upvotes: 2
Reputation:
Usually you can exchange CSS classes conditionally as follows:
<ng-template [ngClass]="{red: row.value >= 100, white: row.value < 100}">
Of course you have to define the CSS-styles behind both classes red and white in your CSS-file.
Upvotes: 2