0

I need to add some classes to host component conditionally. it's simple: add:

@HostBinding('class.app-ltr') isLTR: boolean = true;

and change isLTR in the code; but suppose I need 10 5 or 6 classes, then I need to add to all project components, it cause duplicated code.
what can I do?

I tried to create directive and append to component host, but this feature is not exist.
then I tried to create base component, but parent component doesn't effect.
then I tried to create custom decorator, but not success.

what is best practice?

user3400838
  • 55
  • 3
  • 10
  • check if this already answered post helps. I guess it covers maximum scenarios. Just have a look https://stackoverflow.com/questions/34641281/how-to-add-class-to-host-element – Wahab Shah Nov 12 '21 at 07:35
  • as I said in my question, I know how to add class to host element, but I search for a solution to add class to all components, without duplicating code, your link just explain to add class to host element. – user3400838 Nov 12 '21 at 08:04

0 Answers0