I am trying to preview a pdf document inside AngularJS app.
From my Web API, I am sending as bytes
[Route("PdfData")]
[HttpGet]
public byte[] GetPdfData()
{
BlobService bs = new BlobService();
var blobPdfContent = bs.PdfRecordsInBytes("Sample.pdf");
return blobPdfContent;
}
My angularJS code is as under
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<embed ng-src="{{content}}" style="width:200px;height:200px;"></embed>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', [ '$scope', '$sce','$http',function($scope,$sce,$http) {
$http.get("http://localhost:67845/PdfData")
.then(function(response) {
console.log(response.data);
$scope.content = $sce.trustAsResourceUrl(response.data);
}); }]);
</script>
</body>
</html>
In the console, i am able to find the byte data but nothing is previewed.... what is that i am missing?
console
But browser