I am working on moving an angular 1.x site to a new angular 2.0 site I created the site using angular-cli 1.0.0-beta.15.
I have a button to export some data to a CSV fi
Install the Library as follows,
npm install file-saver --save
This will solve your problem.
just use this import statment
import * as fileSaver from 'file-saver';
On angular-cli you should:
1) install the library to your node_modules:
npm i -S file-saver
2) add reference of js file on 'scripts' in angular-cli.json file:
"scripts": ["../node_modules/file-saver/FileSaver.js"]
3) on your typings.d.ts file :
declare function saveAs();
after that you can use saveAs() everywhere you need example:
export class MyClass{
constructor(){
saveAs(blablabla...)
}
}
Good Luck!
Install the new TypeScript 2 version.. that should work..