Angular 2: File Saver

Simon picture Simon · Jan 5, 2017 · Viewed 22.3k times · Source

iam trying to implement a download button in my Angular 2 application. I have used these tutorials: http://alferov.github.io/angular-file-saver/ https://coryrylan.com/blog/angular-2-cli-adding-third-party-libraries

So i installed file-saver by: npm install angular-file-saver

But import FileSaver from 'file-saver'; or import FileSaver from 'angular-file-saver'; doesnt work.

Error: Cannot find module 'file-saver'.

How do i get this working?

Thank you

Answer

Julien Jacobs picture Julien Jacobs · Jan 12, 2017

http://alferov.github.io/angular-file-saver/ is a AngularJS service so it won't work for Angular2.

Refer to the one of the many SO questions already answered