Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error GET http://localhost:4200/styles.css but I'm able to use these styles. Whats the deal?

Tags:

html

angular

I'm receiving an error in my angular 2 project where in the chrome developer tools console there is a message saying GET http://localhost:4200/styles.css with a red x to the left of it. I'm able to use these styles though so what's the deal?

This is my index.html file:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Scorekeeper</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="./styles.css">
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

enter image description here

like image 267
FlashBanistan Avatar asked Mar 17 '17 18:03

FlashBanistan


2 Answers

Remove that link to your stylesheet from your index.html. You're using the angular-cli and in your configuration, styles.css is being included by the angular-cli. Your link tag in the HTML isn't doing anything.

(The angular cli is also dynamically injecting a link tag for that style into your html, which is why 'it works').

like image 128
snorkpete Avatar answered Nov 09 '22 14:11

snorkpete


Remove your styleSheet path from index.html and link it through angular-cli.json like this styles:

 [
        "styles.css",
        "css/style.css",
        "css-link/bootstrap.css"
       ]
like image 34
satya Avatar answered Nov 09 '22 14:11

satya