Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directive specific styles in Angular 2

I have some directives in my application which are loaded only in certain components. Currently all the styles related to these directives are globally defined in style.css.

Instead of adding these styles globally, is there a way I can hook separate style URLs for directive just like how we do in components.

e.g

@Directive ({
    selector: '[foobar]',
    styleUrls: [
       'foobar.directive.css'
    ]
})
like image 490
Body Avatar asked Aug 31 '25 06:08

Body


1 Answers

There is no way to add styles to directives, only to components.

See also

  • https://angular.io/docs/ts/latest/api/core/index/Directive-decorator.html
  • https://angular.io/docs/ts/latest/api/core/index/Component-decorator.html
like image 50
Günter Zöchbauer Avatar answered Sep 02 '25 21:09

Günter Zöchbauer