Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS scope only to an entire module in Angular

I am doing a lazy-loading to a module, and I want to load a CSS file when that module is loaded. The CSS file should only affect that particular module.

I can't put it on styles.css because it would affect the other modules.

Thanks!

like image 989
Jeffrey Delos Santos Avatar asked Dec 07 '25 05:12

Jeffrey Delos Santos


1 Answers

I have manage to add customer style for each module by create a style file for each module and add this style file in the component stylr list

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.module.scss' , './app.component.scss' ],
})

or you can use scss impot inside the component style file

app.component.scss

@import './app.module.scss';
like image 144
Muhammed Albarmavi Avatar answered Dec 09 '25 01:12

Muhammed Albarmavi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!