0
我對AngularJS非常陌生。我需要幫助才能擺脫下面提到的情況。我試圖在按鈕點擊的新標籤中打開一個PDF文件。我正在解決的代碼如下。新標籤沒有打開。任何指導將不勝感激。AngularJS在新選項卡中打開PDF
$http.get('/api/services/downloadpdf/' + scope.invoice.id, { responseType: 'arraybuffer' }).then(function (response) {
var file = new Blob([response.data], { type: 'application/pdf' });
file.name = 'invoice.pdf';
var fileUrl = URL.createObjectURL(file);
$window.open(fileUrl);
});