Angular 4 - change color dependent on value

后端 未结 2 2035
小蘑菇
小蘑菇 2021-01-04 18:05

I\'m working with Angular 4 and I have a problem with conditional style changing. I have a table and values in it. I need the values in a column to be changed depending if t

2条回答
  •  渐次进展
    2021-01-04 19:00

    Use ngStyle with a method as expression. Add the following method to your component:

    public getColor(balance: number): string{
       return balance > 0 ? "green" : "red";
    }
    

    And in template use it as expression:

     {{row.availableBalance}}
    
    

提交回复
热议问题