Angular add class dynamically

前端 未结 3 1253
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 04:05

Is there a way to add a class from the .ts file, using Angular solutions

I want to d

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 04:33

    You can use ngClass directive:

    Simple as that! myDiv will have the class myCSSclass only when the condition evaluates to true. This condition can be set in your typescript file or in the template.

提交回复
热议问题