Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2: File Saver

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

like image 782
Simon Avatar asked Dec 08 '22 19:12

Simon


1 Answers

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

  • Angular 2 Best approach to use FileSaver.js
  • Use Filesaver js with angular2
  • Angular2 FileSaver.js
like image 154
Julien Jacobs Avatar answered Dec 24 '22 21:12

Julien Jacobs