Thiago Nascimento
Thiago Nascimento

Reputation: 1155

Angular 2 Material can't load style

I'm starting to develop an web app in Angular using the Angular Material library for the interface. But I'm getting an error when trying to import a prebuilt theme. In order to import it, I added <link rel="stylesheet" href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css"> to my index.html file but when i run ng serve I cannot get the file.

Upvotes: 10

Views: 10377

Answers (3)

Tejashree
Tejashree

Reputation: 810

If you don't find any solution just add angular material again. It won't affect your code but add the CSS. Don't forget to re-start the angular server.

ng add @angular/material

Upvotes: 0

Christopher Moore
Christopher Moore

Reputation: 3099

If you are using angular-cli follow their steps for including Angular-Material.

Ensure you have the below imports in src/styles.css

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
@import '~https://fonts.googleapis.com/icon?family=Material+Icons';

It's slightly different to what angular-material suggest on their own Getting Started site but it worked for me.

Upvotes: 13

Kimy BF
Kimy BF

Reputation: 1079

Check that your path is correct. I had the same problem and I fixed the path: Mine is

 <link rel="stylesheet" href="lib/@angular/material/core/theming/prebuilt/indigo-pink.css">

Upvotes: 2

Related Questions