$scope.downloadDocument = function()
{
// Here we are passing URL from where we are going to download file to browser
var documentUrl =
{
'FileName': $scope.selectedRow[0].Url
};
// following method will give call to javascript method
Download($scope.selectedRow[0].Url)
};
function Download(url)
{
// Here we identifying browser
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isFirefox = typeof InstallTrigger !== 'undefined';
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
var isChrome = !!window.chrome && !isOpera;
var isIE = /*@cc_on!@*/ false || !!document.documentMode;
if (isChrome || isFirefox)
{
var save = document.createElement('a');
save.href = url;
save.target = '_blank';
save.download = $scope.selectedRows[0].Name;
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0,
false, false, false, false, 0, null);
save.dispatchEvent(evt);
(window.URL || window.webkitURL).revokeObjectURL(save.href);
}
if (isIE) {
// Force downloading of pdf files (it will NEVER allow any browser specific pdf-reader to render/open your pdf files): var _window = window.open(fileURL, '_blank');
// To force downloading pdf uncomment following line of code and comment above line
// var _window = window.open(url, '', 'left=10000,screenX=10000')
_window.document.close();
_window.document.execCommand('SaveAs', null, url)
_window.close();
}
};This code snippet is for Force browser to download/save files like PDF/HTML/PHP/ASPX/JS/CSS/etc.On disk i am using Angular method to call javascript method.