Tuesday, 15 January 2013

javascript - AngularJS - Show byte array content as image -



javascript - AngularJS - Show byte array content as image -

i'm searching database image byte array. want show content file using markup image, doesn't work here.

// controller image , set $scope. function mycontroller($scope, $http, $location) { var url = '/json/findimage?id=1'; $http.get(url).success(function(result) { $scope.image = result.image; } } // html <!-- doesn't work --> <img src="{{image}}" /> <!-- doesn't work --> <img ng-src="{{image}}" />

any idea? give thanks all!

use ng-src in next format

<img ng-src="data:image/jpeg;base64,{{image}}">

don't forget add together sanitization filter data not marked unsafe angular

$compileprovider.ahrefsanitizationwhitelist(/^\s*(https?|file|ftp|blob):|data:image\//);

javascript angularjs

No comments:

Post a Comment