在页面加载到点击打开的模态表单后,我将尝试加载图像。
我的图像标签如下所示:
<img src="/src/files/bstand{{detailEntry.bearbeitungsstand}}.png">
图片来源正确。但是当我加载页面时,我的变量详细信息条目是空的,因为我是通过单击按钮来填充它的。 所以控制台向我显示 404 错误,网址为: “/src/files/bstand.png” 哪个不存在 当点击按钮时,图像已正确加载。
我记得我在 Angular 1中使用了ng_src
,我想等效的喊叫是[src]
,但它不起作用。
感谢您的回答!
最佳答案
你可以用ngIf等待detailEntry
<img *ngIf="detailEntry.bearbeitungsstand" src="/src/files/bstand{{detailEntry.bearbeitungsstand}}.png">
关于javascript - Angular2 [src] 动态加载图像时导致 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44972713/