Angular2 - Set A Different Color to an element Depending On Value

前端 未结 5 1286
臣服心动
臣服心动 2020-12-06 02:28

I am new to Angular2 and was wondering how I go about setting a font color to an element depending on the value.

My scenario is: if the value of the inp

5条回答
  •  执笔经年
    2020-12-06 03:10

    There are two solutions to change font color but depends on you requirement

    1. If you requirement is change inline style then you can use angular NgStyle Directive which Update an HTML element styles for you..

    NgStyle directive Ex:

    
    
            ---------------------- OR -----------------------------------
    
    
    
    1. If you requirement is change class then you can use angular NgClass Directive which Adds and removes CSS classes on an HTML element...

    NgClass directive Ex:

    
    

提交回复
热议问题