When viewing an HTML file containing the following code:
<div>
<img src="New-Google-Logo.png"/>
</div>
The image file New-Google-Logo.png is expected to load from the same folder as the HTML file. However, after running ng serve, the HTML page loads successfully with all other content except the image. It was attempted to directly link to an external image (e.g. www.google.com/images/x.png) and that worked, but the local file failed to load.
Folder Structure :
src
-app
-logincomponent
- logincomponent.html
- logincomponent.css
- New-Google-Logo.png
- logincomponent.ts
-homecomponent
- homecomponent.html
- homecomponent.css
- homecomponent.ts
The New-Google.png file is referenced within the logincomponent.html as shown above.
Another approach was tried :
src
-app
-logincomponent
- logincomponent.html
- logincomponent.css
- Images
- New-Google-Logo.png
- logincomponent.ts
And referenced in the HTML like this:
<div>
<img src="./images/New-Google-Logo.png"/>
</div>
Unfortunately, neither of these methods worked as expected.