3
votes

Assume that you want to create a directive in AngularJS that requires an external CSS file.

Are there any best practices on where to store the directive's CSS content?

Edit : I am after a solution that in order to copy my directive to another anguarljs app, I will only need to copy the directive code and not have to go over all my CSS.

In the case where there is a templateUrl parameter in the directive, I guess the best place to put the directive's CSS is the HTML template, or not?

1
Css can be stored where you keep all your css files itself like a content folder. you can follow best practices to structure your Angular JS related files though.ssilas777
I am after a solution that in order to copy my directive to another anguarljs app, I will only need to copy the directive code and not have to go over all my CSS.Zouzias
Its clear now, better you edit your question for better clarity then.ssilas777

1 Answers

0
votes

If you keep the html template in a separate file I would suggest you keep the css separately too. In this case you could use a tool like grunt or gulp to bring all those separate directive css together

If the html template is inside the directives definition the best choice would be to keep the css as a style tag provided that the style sheet is a must have and is as malleable as possible