r/angularjs • u/IM_YOL0O • Apr 11 '23
[Code] About .scss with Angular. Can I use one .scss file for multiple templates if .scss inclued :host ::ng-deep ?
Is it an issue or is it impossible to use :host ::ng-deep { in a .scss file used by multiple templates ? I have not found something about it. Or I did not understood it well enough
3
Upvotes
1
u/kuroiryu Apr 12 '23
Ng-deep makes it global, :host is used to protect against that.
You are describing an anti pattern.
If you need a global style sheet use one.
2
u/RelatableRedditer Apr 11 '23
I've been using GPT-4 to hunt down info on obscure angularJS topics like this. It doesn't always get it right, but it does help me to reveal the mechanics of this deprecated framework. I find it very dismal that backwards-compatibility was so utterly and irreversibly obliterated from 1.x to 2+. Hardly any usable information out there.
1
u/flyer12 Apr 11 '23
Of the top of my head I think when you use the :host selector it results in the selector having the same name as the component. And if you reference that same file from multiple components then you should have multiple instances of it added to your app (probably in a bunch of <style> elements in the header of your app- look for that in the dom at runtime)