I finally found a solution that satisfies all my requirements and works in IE11, FF and Chrome (and degrades the appearance of OK in Safari ...).
, Blob, , . IE ( API) Chrome/FF ( ).
, Angular :
myApp.factory('Download', [function() {
return {
openAsFile : function(response){
var contentTypeStr = response.headers('Content-Type');
var tokens = contentTypeStr.split('/');
var subtype = tokens[1].split(';')[0];
var contentType = {
type : tokens[0],
subtype : subtype
};
var contentDispStr = response.headers('Content-Disposition');
var proposedFileName = contentDispStr ? contentDispStr.split('"')[1] : 'data.'+contentType.subtype;
var blob = new Blob([response.data], {type : contentTypeStr});
if (typeof window.navigator.msSaveBlob !== 'undefined'){
window.navigator.msSaveBlob(blob, proposedFileName);
}else{
var downloadUrl = URL.createObjectURL(blob);
var a = document.createElement("a");
if (typeof a.download === 'undefined') {
window.open(downloadUrl);
}
var link = document.createElement('a');
link.href = downloadUrl;
link.download = proposedFileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
}
}]);
$http. POST:
$http.post(url, {property : 'value'}, {responseType: 'blob'}).then(function(response){
Download.openAsFile(response);
});
responseType. CSV- UTF-8 ( 16), , Excel , éè .. CSV Excel, Windows 1252, . responseType Blob .
: . CSV! - !