JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="app" ng-controller="MainCtrl">
<img ng-src="data:image/jpeg;base64,{{image}}" />
<img ng-src="data:image/jpeg;base64,{{image2}}" />
</div>
JavaScript
var app = angular.module('app', []);
app.controller('MainCtrl', function ($scope, $http) {
$http.get('http://lorempixel.com/50/50/', {responseType: "arraybuffer"}).success(function (resp) {
$scope.image = resp;
// Prep the response for Base64 encoding
var uInt8Array = new Uint8Array(resp);
var i = uInt8Array.length;
var binaryString = new Array(i);
while (i--)
{
binaryString[i] = String.fromCharCode(uInt8Array[i]);
}
var data = binaryString.join('');
// Base64 encoded image and assign it to the scope
$scope.image2 = window.btoa(data);
});
});