Angular - including CSS file in index.html

I am trying to use the library angular2-busyin an angular project created using the CLI, but I have a problem importing the stylesheet:

<link rel="stylesheet" href="/node_modules/angular2-busy/build/style/busy.css">

The browser tells me that it cannot find the file, even with the correct path. I also checked that the file exists and it does. When I take out rel="stylesheet", I do not get an error, but then the animation does not work.

enter image description here

Here is the package I'm trying to use if anyone is interested: https://www.npmjs.com/package/angular2-busy

+4
source share
3 answers

Angular The CLI has its own way to initialize your global css / js.

They are located in the configuration. .angular-cli.json

"styles": css

:

"styles": [
   "../node_modules/angular2-busy/build/style/busy.css",
   "styles.css"
],

, .

+4

Try

  <link rel="stylesheet" href="node_modules/angular2-busy/build/style/busy.css" >
+1

You do not have enough self-closing / at the end of your code. Perhaps the browser does not fix this for you.

<link rel="stylesheet" href="/node_modules/angular2-busy/build/style/busy.css" />

Also, removing rel = "stylesheet" will definitely not fix the problem, since the browser needs to know exactly which link you are accessing.

If the closing tag fix does not work, your path is wrong. You can also try adding ../ to the beginning of your journey. This will make it relative to the folder in which the site is located.

<link rel="stylesheet" href="../node_modules/angular2-busy/build/style/busy.css" />
0
source

Source: https://habr.com/ru/post/1681909/


All Articles