3
votes

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.

1
Isn't their file a .scss file ? you imported a css file. - user4676340
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"> - Hamed Baatour
Yes, but I have an error, that it can not find it : GET localhost:4200/node_modules/@angular/material/prebuilt-themes/… - Max K
Is you style file a *.css or a *.scss file? And did you import it to your styles object in .angular-cli.json? - Edric

1 Answers

2
votes

in your angular-cli.json under :

"apps": [

  //....

"styles": [

   //... , 

  "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" //<--add this
  ],
]