Angular 2 add multiple classes via [class.className] binding

后端 未结 2 676
忘掉有多难
忘掉有多难 2020-12-24 10:46

While adding a single class works great in this way -

[class.loading-state]=\"loading\"

But how do I add multiple classes Ex if loading

2条回答
  •  梦谈多话
    2020-12-24 11:22

    You can do this by simply using ngClass :

    Here first,second and third are the name of the classes.

    And instead of true/false , you can directly put your conditions over there

     
    ...

    In your case

     
    ...

    Or Shorter Veriosn (as @matko.kvesic commented)

    ...

提交回复
热议问题