Applying a style to a table cell depending on a formula

Not technically a Canvas question.

I have a table created with an ng-repeat, based on a returned dataset. What I want to do is change the text colour in a cell, not row, based on a formula. i.e. if the value is less that 500 then red text.

I’m assuming I can use something like ng-class="{‘class’: expession}". If this correct, or should I use something like ng-style

Brian

Just used ng-style in the end

ng-style="{color: x[14] < (x[6] - (x[6] * .05))? ‘Red’:‘Black’}"

Hi @bknott,

Yep that is the correct syntax, you could also use ng-class the same way and it will be easier to change colours.

Tim
I thought the correct syntax is
ng-style="{‘color’: x[14] < (x[6] - (x[6] * .05))? ‘Red’:‘Black’}"

Note the quotes around the color since attribute can have a ‘-‘ e.g. ‘padding-top’ the minus if not in quotes is not going to work best to keep it in quotes all the time I think.
Ilia