0

I'm trying write the path of the local images into the project and It seems to show me an undefined image. enter image description here

as you can see I'm in the app.component.html I want to make

src="img/profile.png"

but in the browser I get this error

profile.png Failed to load resource: the server responded with a status of 404 (Not Found)

do I wrong with the path?

Manspof
  • 598
  • 26
  • 81
  • 173
  • Hi Adir, From your screen grab src="img/profile.png" path is not correct. So try with the path src="img/portfolio/profile.png". I hope this is your solution – Malathy Venkatesan Aug 04 '17 at 08:51
  • no, the profile.png not into the portfolio, it's into the img – Manspof Aug 04 '17 at 08:51
  • @MalathyVenkatesan actually I don't think it is - if you look carefully that folder is not expanded. When setting the src I believe it is relative to the `` in your `index.html` can you check that? You may also want to try putting it in an assets folder as [the top answer to this question](https://stackoverflow.com/questions/40230473/how-to-serve-up-images-in-angular2) suggests – 0mpurdy Aug 04 '17 at 08:53
  • Try this solution src="/img/profile.png" – Malathy Venkatesan Aug 04 '17 at 08:55

2 Answers2

4

You need to create this img folder in assets which is out of src folder. And then try to use that path like below

<img src="./assets/img/profile.png">
The Hungry Dictator
  • 3,444
  • 5
  • 37
  • 53
3

I found solution for that works. I just move the folder img to assets and then I write this line

src="assets/img/profile.png"
Manspof
  • 598
  • 26
  • 81
  • 173