First of all your request response type has to be arraybuffer.
function openFile(response,fileName,saveFile){
var fileURL;
var contentType = response.headers('Content-Type');
var blob = new $window.Blob([response.data], { type: contentType });
if(saveFile){
saveAs(blob, fileName);
}else{
if($window.navigator.msSaveOrOpenBlob){
$window.navigator.msSaveOrOpenBlob(blob , fileName);
}else{
fileURL = URL.createObjectURL(blob);
$window.open(fileURL, '_blank');
}
}
}
$window is an AngularJS service - reference to browers window object.
$window.navigator.msSaveOrOpenBlob - it's a method specific to IE browser that supports creating and downloading files insted of Blob URL which isn't supported by IE.
saveAs - https://github.com/eligrey/FileSaver.js/