加载图片src使用含有AngularJS的base64数据的变量 [英] Loading image src using a variable containing base64 data in AngularJS
问题描述
我试图找到加载含有的base64
连接codeD映像数据(例如使用画布拉扯变量的图像源的正确方法 toDataURL();
)
I am trying to find the right way to load a image source from a variable containing base64
encoded image data (for example pulled from a canvas using toDataURL();
).
起初,我只是尝试这样的:
At first I just tried it like this:
<img src="{{image.dataURL}}" />
在图像与含有的base64
数据的变量 dataURL
A范围的变量。这实际上是工作pretty很好,唯一的问题是我在控制台收到了 404
错误。事情是这样的:
where the image is a scope variable with a variable dataURL
containing the base64
data. This is actually working pretty well, the only problem is that I get a 404
error in my console. Something like this:
GET http://www.example.com/%7B%7Bimage.dataURL%7D%7D 404(未找到)
没那么pretty。当我尝试了更多的棱角风格的解决方案是这样的:
Not so pretty. When i tried a more angular style solution like this:
<img data-ng-src="image.dataURL" />
图像不加载在所有。
我做了一个小提琴,你可以找到<大骨节病> 这里 骨节病>
任何建议如何在我的控制台摆脱这种错误的?
Any suggestions how to get rid of this error in my console?
响螺兔子是正确的。这&LT; IMG数据-NG-SRC ={{image.dataURL}}/&GT;
工作...
Gruff Bunny was right. This <img data-ng-src="{{image.dataURL}}" />
is working...
工作方案可以找到<大骨节病> 这里 骨节病>
推荐答案
在NG-SRC的内容需要进行插值:试试这个:
The content of the ng-src needs to be interpolated: Try this:
<img data-ng-src="{{image.dataURL}}"/>
这篇关于加载图片src使用含有AngularJS的base64数据的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!