All static asset files/directories need to be listed in the angular-cli.json
file.
Adding assets
To add your assets you can either:
- Put your image file in the default
assets
folder (which is already listed in theangular-cli.json
file. - Or add a new directory inside of
app/
(e.g. in your case you could useapp/images
, and then reference that inangular-cli.json
)
angular-cli.json:
{
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico",
"images"
]
}
]
}
Referencing files
Like @jali-ai mentioned in the comments background-url
should be background-image
and you can refer to your asset like this:
.image {
background-image: url('images/image.png');
}
Here is an example of the angular-cli.json file and a reference to an asset