Is there a way to include a universal CSS file in Angular 2 applications? Currently, I have multiple components that share the same button styling, but each component has its own CSS file containing the styles. This setup makes it difficult to make changes.
I came across a suggestion on Stack Overflow to add the following:
import { ViewEncapsulation } from '@angular/core'; //insert this line
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
encapsulation: ViewEncapsulation.None //include this line
})
I followed the instructions and added the ViewEncapsulation code to the root component. Then, I moved the CSS styling to the main app CSS file (app.component.css) and removed the styling from individual component files, but unfortunately, it did not work as expected.
Is there an effective way to incorporate a global CSS file in Angular 2? Do I need to make any additional adjustments to the individual components for them to access the global CSS?