I am creating an angular application with 3 different parts which are accessible by 3 different types of users: admin, landowner, and buyer. The buyer section is a new section and I need to create a new theme / styles for this section. There are component specific .scss files as well as global styles which are contained in a _global.scss
file and a _layout.scss
file. There is also a styles.scss
file which is declared in the styles
section of the angular.json
file with injection set to true
. I only want the global styles (_global
and _layout
) to be accessible to admin and landowner components of the application, and not the buyer components. The admin can also access all routes, so they will be able to navigate anywhere they like. My app-routing.module
routing module looks something like this:
app.component
- '' path redirects to login.component
- login.component
- admin-dashboard.component
- router-outlet with subroutes
- admin-project.component
- router-outlet with subroutes
- landowner-dashboard.component
- router-outlet with subroutes
- buyer.dashboard.component
- router-outlet with subroutes
So far I have tried switching the ViewEncapsulation
to None
for the top level components being mounted above (i.e. login.component
, admin-dashboard.component
, etc) in this routing module, and then importing the _global.scss
and _layout.scss
into each of those top level components. That works until an admin starts navigating in between sections and the styles from the admin section start to override the styles from the buyer section. I have tried to edit the angular.json
to set inject: false
for the global style sheets mentioned, and then importing those stylesheets for all the top level components, with the same issue. I have tried wrapping the global styles in a class, and then setting the containers for all the admin and landowner components to have this class, and the styles were not being applied. I have also followed the angular guides for creating multiple themes, and the styles were not being applied (there would also be too much code to paste here). Has anyone run into this type of problem and know how to get it to work at a high level?
I think what you are looking for are module scoped style, unfortunately this is not a feature currently available.