如何prevent NG-src的数据到达之前加载图像? [英] How to prevent ng-src to load image before data arrives?
问题描述
HTML
<img ng-src="{{plugins.filesPath.album_images.image}}{{album.cover_image}}" alt="{{album.title}}" />
在运行应用程序,它会显示错误:
While running the app, it shows error:
GET http://url.com/myApp/files/album_images/image/ 403 (Forbidden)
<一个href=\"http://url.com/myApp/files/album_images/image/\">http://url.com/myApp/files/album_images/image/\"是价值{{plugins.filesPath.album_images.image}}
"http://url.com/myApp/files/album_images/image/" is the value of {{plugins.filesPath.album_images.image}}.
它显示错误,因为它去所有数据到达之前加载图像。
It shows error because it goes to load the image before all data arrives..
如何prevent这个错误控制台?
How can i prevent this error in console?
推荐答案
尝试使用条件模式条件和放大器;&安培;真正||假
因此修改 NG-SRC
属性是这样的:
Therefore modify ng-src
attribute like this:
<img ng-src="{{ album && plugins.filesPath.album_images.image + album.cover_image || '' }}" alt="{{album.title}}" />
随着这一变化,直到数据到达的src
属性的内容是空的。
的来源:的<一个href=\"http://stackoverflow.com/questions/13999659/conditionally-change-img-src-based-on-model-data/13999837#13999837\">Conditionally基于模型数据变化IMG SRC
Source: Conditionally change img src based on model data
这篇关于如何prevent NG-src的数据到达之前加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!