3

I am trying to add angular material2 to my project. (I use angular-cli) However, I get the following error when I run ng serve:

material.es5.js:177 Could not find Angular Material core theme. Most Material components may not work as expected. For more info refer to the theming guide: https://material.angular.io/guide/theming

Although I added it to my global style file.

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

How can I fix it? Thank you.

4
  • Isn't their file a .scss file ? you imported a css file. Commented May 24, 2017 at 9:16
  • you can try to include the following in your index.html head : <link href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet"> Commented May 24, 2017 at 9:21
  • Yes, but I have an error, that it can not find it : GET localhost:4200/node_modules/@angular/material/prebuilt-themes/… Commented May 24, 2017 at 9:33
  • Is you style file a *.css or a *.scss file? And did you import it to your styles object in .angular-cli.json? Commented May 24, 2017 at 13:54

1 Answer 1

2

in your angular-cli.json under :

"apps": [

  //....

"styles": [

   //... , 

  "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" //<--add this
  ],
]
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.