How to add "class" to host element?

Discussão em 'Angular' iniciado por lascarayf, Dezembro 9, 2024.

  1. lascarayf

    lascarayf Guest

    I dont't know how to add to my component <component></component> a dynamic class attribute but inside the template html (component.html).

    The only solution I found is to modify the item via "ElementRef" native element. That solution seems a little complicated to do something that should be very simple.

    Another problem is that CSS has to be defined outside component scope, breaking component encapsulation.

    Is there a simpler solution? Something like <root [class]="..."> .... </ root> inside the template.

    Continue reading...

Compartilhe esta Página