Apply CSS at module level in angular 2
No, right now you can't do that. It is a pending feature (See this and this).
However you can apply style to bootstrapped component of your module with /deep/ strategy. See this for more info
Angular 2 share the same css file across the module
Yes you can. Simply create a file, shared.scss
for example. Now you can import it in you components style: @import './styles/shared.scss';
You could also add it to your styleUrls
in your component.
separate styles for separate module in Angular 5
I found the solution. We can disable or enable css files in component.
document.styleSheets[2].disabled = false;
or
document.styleSheets[2].disabled = true;
that's it.
How to bundle Angular 2 component css?
I managed to achieve this with webpack
and a special angular2-template-loader
plugin. This is the config from webpack 2:
module: {
rules: [
{
test: /\.ts$/,
use: ['awesome-typescript-loader', 'angular2-template-loader']
}
Basically what it does, it replaces templateUrl
and styleUrls
with inline template
and styles
and just stores them in a string as a separate "module".
How does it work
The angular2-template-loader searches for templateUrl and styleUrls
declarations inside of the Angular 2 Component metadata and replaces
the paths with the corresponding require statement. If keepUrl=true is
added to the loader's query string, templateUrl and styleUrls will not
be replaced by template and style respectively so you can use a loader
like file-loader.The generated require statements will be handled by the given loader
for .html and .js files.
P.S. The whole set up can be found in Anagular tutorial.
Related Topics
How to Change Font-Size of a Tag Using Inline CSS
Did Chrome 72 Break 'Data:Image/Svg+Xml;Utf8' for CSS Background Svgs
Change The Color Profile of a Page in CSS
Add Additional Box-Shadow to an Element Where Existing Shadow Is Unknown
CSS: Nth-Of-Type() and: Not() Selector
Is There an "Official"/Standard CSS3 Gradient Syntax
Bootstrap 3 and .Col-Xs-* - Do You Not Need Rows of 12 Units
How to Fix Collapsing Top and Bottom Margins
Selecting an Element That Has a Specific Child
How to I Solve This SASS Interpolation Issue
Twitter Bootstrap Thumbnail Caption to The Right
How Do Browsers Parse/Render CSS
CSS Firefox - How to Deactivate The Dotted Border ( Firefox Click Indicator )
Problem with Position Absolute in Ie7, Div Moves 10Px to The Right
When Do We Use "Position:Relative" in CSS