简体   繁体   中英

Why is Image not showing in angular home component project?

I am working on an angular project but trying to add an image to a table row in the html component . The image is not showing and I have tried many ways to make it work but still can't get it to show . Here is the home.component.html code :

The Images are in a folder named "images" in the project folder under the e2e folder , atop the node_modules folder


<table>
<tr>
<td>
<img src="images/Larissa.jpg" alt="investor1">
<p>"Trusted and quick profit. I use this website many times and I recommend it."</p>
</td>
<td>
    <img src="images/petroski.jpg" alt="investor2">

    <p>"I feel safe with the knowledge that my  investment is secured and safe with Coin Rush."</p>
</td>
<td>
<img src="images/marie.jpg" alt="investor3">
<p>"Thank you i am very impressed”</p></td>
</tr>
</table>

Images are loaded from those folders which are set static or we can say assets folder. If you want to load specific resource, then you must put that resource under assets.

"assets": [
  "src/assets"
 ],

If you want to create new folder, then provide that folder path under assets in angular.json .

And provide relative path starting with your folder. For example,

Your image is under the path src/assets/images/1.jpg

Then you need to provide path as

<img src="assets/images/1.jpg">

e2e folder is not a public folder. It will be used by e2e testing. You can google it by End to end testing (E2E). https://coryrylan.com/blog/introduction-to-e2e-testing-with-the-angular-cli-and-protractor

您必须添加一个名为assets的目录,在此目录中您可以存储项目中所需的所有图像,要使用这些图像,您必须在图像标签的src属性中提供图像的相对路径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM