How to download file from angularjs controller?

beginer
beginer
1544 Points
52 Posts

I am using following code in angularjs controller file:

var anchor = angular.element('<a/>');                
anchor.attr({
     href: '/Download/MyFile?id=' + myId + '&format=pdf'
  })[0].click();

It's working fine in chrome. But not working in firefox mozilla.

Any one have solution for this.

Views: 11306
Total Answered: 1
Total Marked As Answer: 1
Posted On: 15-Sep-2017 01:23

Share:   fb twitter linkedin
Answers
Smith
Smith
2890 Points
78 Posts
         

I think, you can use window.location dom object as:

window.location.href = '/Download/MyFile?id=' + myId + '&format=pdf';
Posted On: 15-Sep-2017 01:31
thanks
 - beginer  11-May-2018 20:23
 Log In to Chat