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!

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi Thanks for answer ! But please try to understand my question. This is not what I find for.
@PiyaModi Please check my edited answer, it may contain your solution.
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 Surely the file can be manually accessed from its download destination. I am not sure sure otherwise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.