Combine [NgStyle] With Condition (if..else)

前端 未结 10 1522
暗喜
暗喜 2020-12-04 20:55

I have read NgStyle Documentation For Angular 2, and it is a little bit confusing for me. How do I use NgStyle with condition like (if...else) to set background image of any

10条回答
  •  难免孤独
    2020-12-04 21:50

    Server with ID: {{serverId}} is {{getServerStatus()}}

    or you can also use something like this:

    Server with ID: {{serverId}} is {{getServerStatus()}}

    and in the *.ts

    getColor(){return this.serverStatus === 'Offline' ? 'red' : 'green';}
    

提交回复
热议问题