0

I'm having angular project consist of Frontend and admin. I want to scale my project in such a way that I use different CSS for both admin and frontend.

Structure of my project is as follows:

--app
   --admin // Admin Module
     --admin.module.ts
     --admin.component.ts
     --admin-routing.module.ts
     --admin.component.css
     --admin.component.html

  --web // Frontend Module
     --web.module.ts
     --web.component.ts
     --web-routing.module.ts
     --web.component.css
     --web.component.html 

--app.module.ts
--app.component.ts
--app-routing.module.ts
--app.component.css
--app.component.html

I've defined my CSS for web(Frontend) in .angular-cli.json file.

"styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.css"
      ],

How can I load different CSS file for admin and the web? Also is there any better approach to include multiple modules in same project?

1

2 Answers 2

2

You can define the global css properties that are common for both admin and remaining users in the "styles.css" file and admin specific & remaining user specific css properties could be defined in admin.component.css and web.component.css respectively;Hope this helps

Sign up to request clarification or add additional context in comments.

4 Comments

I tried importing css on module level - @import './assets/styles.css'; , still no results are reflected? What can be the reason
where are you trying to do this import ?? You dont have to import any module level imports ..thats imported by default
Consider I'm writing following css in web.component.css - body { font-family: Montserrat,Montserrat-Light,Montserrat-Regular,Montserrat-Bold,Montserrat-Black,sans-serif !important; padding-top: 100px; } , No results is refected at web level
please post update your code with web component and web component html and do you have any error on the console ?
0

If you have a main component for each module, you just have to attach the .css file to your component in the @Component() decorator.

@Component({
    templateUrl: './admin.component.html'
    styleUrls: ['./admin.component.css']
})

@Component({
    templateUrl: './web.component.html'
    styleUrls: ['./web.component.css']
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.