FrankTheTank
FrankTheTank

Reputation: 785

Resource not found, wrong path?

Am I using the wrong path to load in an image that I downloaded? I am trying to load frank.jpg from about-user.component.html. enter image description here

Why am I getting a 404 not found error for the resource?

Upvotes: 1

Views: 277

Answers (2)

Arjun Panicker
Arjun Panicker

Reputation: 740

Any image you use need to be put in the assets folder. You can then access the images from there.

Check this link on how to access images from assets folder.

Upvotes: 1

Nihal
Nihal

Reputation: 5334

You use the assets array in .angular-cli.json to list files or folders you want to copy as-is when building your project.

By default, the src/assets/ folder and src/favicon.ico are copied over.

"assets": [
  "assets",
  "favicon.ico"
]

make one image folder in assets

put your image in that folder

then in angular-cli.json

"assets": [
        "assets",
        "favicon.ico",
        "static/images"
      ]

images is folder name then give path like ../assets/images/frank.png in src

Upvotes: 1

Related Questions