How to download file from angularjs controller?

beginer
beginer
Member
1328 Points
43 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: 11119
Total Answered: 1
Total Marked As Answer: 1
Posted On: 15-Sep-2017 01:23

Share:   fb twitter linkedin
Answers
Smith
Smith
None
2568 Points
74 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