我正在尝试使用此帖子中建议的方法AngularJS:在angular应用程序中显示二进制文件(.pdf)来显示二进制文件。这在Chrome和Firefox中运行得很好,但是IE 11给了我“错误:拒绝访问”的消息。
有人知道是否与Blob对象有关,并可以指导我正确的方向吗?
这是我的js代码:
$http.get(baseUrl + apiUrl, { responseType: 'arraybuffer' })
.success(function (response) {
var file = new Blob([response], { type: 'application/pdf' });
var fileURL = URL.createObjectURL(file);
$scope.pdfContent = $sce.trustAsResourceUrl(fileURL);
})
.error(function () {
});
还有我的HTML:
<div ng-controller="PDFController" class="modal fade" id="pdfModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" onloadstart="">
<object data="{{pdfContent}}" type="application/pdf" style="width:100%; height:1000px" />
</div>
</div>