Home > database >  Сan't set url for background-image
Сan't set url for background-image

Time:07-15

I want to set the background property. When I specify the path to the image, I get an error. What is the reason? Wrong way?

I successfully add other images from the img directory to the html document: <img src="assets/img/ImageBig.png" alt="model" >. I will be grateful for the answer.

enter image description here

CodePudding user response:

The image path is relative to the file. If your file path is /src/app/article/article.components.scss and the image path is /src/app/assets/img/ImageBig.png, in your case the relative path should be ../assets/img/ImageBig.png.

Some links:

Hope this helps!

CodePudding user response:

This helped: src="assets/img/tyler.png" . And I figured out the following. There is build: {} in angular.json. There is a path to the assets folder (and everything in it gets into the build).

  • Related