AngularJS - 显示字节数组内容的图像 [英] AngularJS - Show byte array content as image
本文介绍了AngularJS - 显示字节数组内容的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索到我的数据库中的图像作为字节数组。我想用标记的图片的显示此内容的文件,但它不会在这里工作。
I'm searching into my database a image as a byte array. I want to show this content as file using the markup image, but it doesn't work here.
// Controller which get my image and put into $scope.
function MyController($scope, $http, $location) {
var url = '/json/FindImage?id=1';
$http.get(url).success(function(result) {
$scope.image = result.Image;
}
}
// HTML
<!-- It doesn't work -->
<img src="{{image}}" />
<!-- It doesn't work also -->
<img ng-src="{{image}}" />
你知道吗?
谢谢大家!
Any idea? Thank you all!
推荐答案
使用NG-SRC按以下格式
Use ng-src in the following format
<img ng-src="data:image/JPEG;base64,{{image}}">
不要忘了为数据
添加消毒过滤器不被标记为不安全
通过角
Don't forget to add a sanitization filter for data
to not be marked as unsafe
by angular
<$c$c>$compileProvider.aHrefSanitizationWhitelist(/^\\s*(https?|file|ftp|blob):|data:image\\//);$c$c>
这篇关于AngularJS - 显示字节数组内容的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文