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.

Edric
  • 24,639
  • 13
  • 81
  • 91
John Doe
  • 3,794
  • 9
  • 40
  • 72
  • Isn't their file a .scss file ? you imported a css file. –  May 24 '17 at 09:16
  • you can try to include the following in your index.html head : `` – Hamed Baatour May 24 '17 at 09:21
  • Yes, but I have an error, that it can not find it : GET http://localhost:4200/node_modules/@angular/material/prebuilt-themes/indigo-pink.css – John Doe May 24 '17 at 09:33
  • Is you style file a `*.css` or a `*.scss` file? And did you import it to your styles object in `.angular-cli.json`? – Edric May 24 '17 at 13:54

1 Answers1

2

in your angular-cli.json under :

"apps": [

  //....

"styles": [

   //... , 

  "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" //<--add this
  ],
]
SeleM
  • 9,310
  • 5
  • 32
  • 51