Answer Detail

How to download file from angularjs controller?

beginer
beginer
50 Points
20 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.

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

Share:   fb twitter linkedin
Answers
Smith
Smith
Participant
348 Points
104 Posts
Marked as answer      

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
banner

Blog

Active User (0)

No Active User!
 Log In to Chat