In my AngularJS webapp I need to load an image from a file and then display it. But it doesn't work.
My plunk is: http://plnkr.co/edit/gpwyUd3Hh6HvrBnt2dR6
My JavaScript is:
var test = function() {
var getImgBytes = function() {
return $http({ url: 'Spa_03.jpg',
method: 'GET',
headers: {'Content-Type': 'image/jpeg'}})
.then(
function(result) {
console.log('load img from file');
$scope.imgTest = result.data;
});
}();
$scope.height = 853;
$scope.width = 1280; }();
My HTML is:
<img ng-src="data:image/JPEG,{{imgTest}}" width="320px" height="213px"/>
Could someone help me to fix the problem ?
Regards.