1

I have angular 2 project which have 2 Modules, one for web and one for admin.

I put the main styles for web in style.css (specified in .angular-cli.json)

@import "../node_modules/bootstrap/dist/css/bootstrap.css";

and it work great, but the style.css code appear every where in both web and admin, i want to separate it completely.

is there any way to set specific CSS style files for each Module?

1 Answer 1

3

for the 2 modules that you have, web module can have:

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

and admin module can have:

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

The file linked in styleUrl only applies to that component. so you can separate the css styles for each component this way.

If your styles are very short and you don't want to create a separate file for each component, there are other ways of applying styles to a particular component: https://angular.io/docs/ts/latest/guide/component-styles.html

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

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.