我正在使用此代码打开文件,它在控制台中显示url,但未在新窗口中打开它。
ft.openFile = function(id) {
FileService.download(id).then(function(resp) {
console.log(resp.headers('Content-Type'));
var blob = new Blob([resp.data], {
type: resp.headers('Content-Type')
});
var url = $window.URL || $window.webkitURL;
var fileUrl = url.createObjectURL(blob);
window.open(fileUrl);
console.log(fileUrl);
})
答案 0 :(得分:1)
ft.openFile = function(id){
FileService.download(id).then(function(resp){
console.log(resp.headers('Content-Type'));
var blob = new Blob([resp.data],{type: resp.headers('Content-Type')});
var url = $window.URL||$window.webkitURL;
var fileUrl = url.createObjectURL(blob);
window.open(fileUrl, '_self'); //same window
//or
window.open(fileUrl, '_blank'); //new window
console.log(fileUrl);
})
答案 1 :(得分:0)
使用此:
window.open(fileUrl, '_blank'));