Angular 4图片src不起作用 [英] Angular 4 Img src is not working
问题描述
文件夹结构:
我有一个图像src在角度4的问题。它一直告诉我,图像没有找到。 a href =https://i.stack.imgur.com/exE5P.png =noreferrer> Here
我正在使用图像在mycomponent。如果在我的组件中,我直接插入
< img src =img / myimage.png
它工作正常,但我检查了html并创建了一个哈希。但我的图像必须dinamically添加到HTML,因为它们是列表的一部分。所以,如果我使用:
< img src ={{imagePath}}> ;
基本上是img / myimage.png,它不起作用。如果我使用
< img [src] =imagePath>
它表示NOT FOUND(htttps://localhost/img/myimage.png) 。你可以帮我吗?
AngularJS
code>< img ng-src ={{imagePath}}> Angular
< img [src] =imagePath>
i'm having a problem with image src in angular 4. It keeps telling me that the image is not found.
folder structure: Here
I am using the image in mycomponent. If in my component I insert directly
<img src="img/myimage.png"
It works fine, but I checked the html and it creates an hash. But my images have to be dinamically added to the html because they are part of a list. So, if I use:
<img src="{{imagePath}}">
which basically is "img/myimage.png" it doesn't work. If I use
<img [src]="imagePath">
It says NOT FOUND (htttps://localhost/img/myimage.png). Can you help me?
AngularJS
<img ng-src="{{imagePath}}">
Angular
<img [src]="imagePath">
这篇关于Angular 4图片src不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!