0

In my application, there is a list of files. I stored this list in the scope.

I had put all files in data-table and i want to download the particular file on which user will click.

All types of file should acceptable.

Is there any directive to download the file as per my requirement.

Thanks!

PiyaModi
  • 213
  • 2
  • 9
  • 22
  • This sounds like something which a quick google search could answer. For example: http://blog.neilni.com/2016/04/23/download-file-in-angular-js/ – Jonathan Smith Oct 03 '16 at 07:48

1 Answers1

1

Try using the JavaScript library named FileSave: https://github.com/eligrey/FileSaver.js/

Call the following in your code:

saveAs(file, 'filename');

More importantly, try searching for this answer before posting, the answer can be found on this site right here: how to download file using AngularJS and calling MVC API?

UPDATE: Try the following:

<a download="content.txt" ng-href="{{ url }}">download</a>

This should create a download link for the file you specify.

Community
  • 1
  • 1
User44
  • 140
  • 8
  • Hi Thanks for answer ! But please try to understand my question. This is not what I find for. – PiyaModi Oct 03 '16 at 10:34
  • @PiyaModi Please check my edited answer, it may contain your solution. – User44 Oct 03 '16 at 12:33
  • Hi, With this I am able to download the file, but that file is not opening. I am using lighttpd server. I don't know whether it is a problem of server! – PiyaModi Oct 04 '16 at 10:01
  • @PiyaModi Surely the file can be manually accessed from its download destination. I am not sure sure otherwise. – User44 Oct 04 '16 at 19:43