HTML File :
<div>
<img src="New-Google-Logo.png"/>
</div>
Here the New-Google-Logo.png is in the same folder as in the html file. But after ng serve the html page loads with other details, but not the image. Tried by directly giving a link for an image (like www.google.com/images/x.png), it works, but local file is not loading.
Folder Tree :
src
-app
-logincomponent
- logincomponent.html
- logincomponent.css
- New-Google-Logo.png
- logincomponent.ts
-homecomponent
- homecomponent.html
- homecomponent.css
- homecomponent.ts
Here the New-Google.png is referred inside logincomponent.html as given above.
Try 2 :
src
-app
-logincomponent
- logincomponent.html
- logincomponent.css
- Images
- New-Google-Logo.png
- logincomponent.ts
And referred in the html like :
<div>
<img src="./images/New-Google-Logo.png"/>
</div>
Both these didn't worked out.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…