2

Actually I got a stylesheet: <link href="../node_modules/@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet"> That file exist, the Webstorm also sees that file in the directory, but somehow Angular2 is unable to load it.

Error: GET http://localhost:4200/node_modules/@angular/material/core/theming/prebuilt/indigo-pink.css

How to make Angular2 load that file? Thanks for any further informations.

The root looks like:

-Main folder

--node_modules

---stuff

--src

---index.html

---styles.css

EDIT On mithunvp.com/angular-material-2-angular-cli-webpack/ there's a hint to use

@import '~https://fonts.googleapis.com/icon?family=Material+Icons';

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

to turn on a prebuilt theme. But once again, even if it's pasted inside the styles.css it returns errors that it cant find it. It cant even find the Material icons, which is a link...

3
  • @DanielA.White What do you mean by web server? Commented Nov 18, 2016 at 14:39
  • what is driving port 4200? Commented Nov 18, 2016 at 14:39
  • @DanielA.White ng serve in Angular 2 Commented Nov 18, 2016 at 14:42

3 Answers 3

1

You shouldn't try to load css like that, even more when you can have sccs source file.

Using angular-cli, I can imagine that you have the file src/styles.scss or .less right ? (unless you decided to use pure css ?!).

So if you're using sass, in src/styles.scss just put :
@import '~@angular/material/core/theming/prebuilt/indigo-pink.css';

Plus, I can imagine what you're trying to do and if you haven't seen Kara's demo with angular-material, I'd recommend you to take a look to : https://www.youtube.com/watch?v=0q9FOeEELPY

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

3 Comments

Im doing everything like in that movie, but somehow Angular2 cant find these files. She is doing it at 4:00 in the movie, everything works for her, but my Angular2 cant find these files. @import '~https://fonts.googleapis.com/icon?family=Material+Icons'; @import '~@angular/material/core/theming/prebuilt/deeppurple-amber.css';
It's fixed. Thank u
what did you do to fix this?
0

To Fix the Issue, Please Inline styles.css from index.html and add it inside angular-cli.json under style Array like

"styles": [
    "../node_modules/bootstrap/dist/css/bootstrap.css",
    "styles.css"
  ],

Hope. It will work

Comments

0

enter image description here

You should use the following statement

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

instead of

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

inside the styles.css.

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.