This projet is an inspiration of eligrey FileSave.js.
The library is full compatible with Angular, and it's simple to use.
Source code can be found on my GitHub.
I made some test on following browsers.
Browser | Version |
---|---|
Firefox | 80 |
Google Chrome | 84 |
Microsoft Edge Chromium | 85 |
npm install @clemox/ngx-file-saver
- Import module
import { NgxFileSaverModule } from '@clemox/ngx-file-saver';
@NgModule({
imports: [ NgxFileSaverModule ]
})
- Declare service
import { NgxFileSaverModule } from '@clemox/ngx-file-saver';
constructor(
private fileSaver: NgxFileSaverService
) { }
- Download file or blob
this.fileSaver.saveUrl(url, 'Test.docx');
const blob = new Blob(['Test de blob'], { type: 'text/plain' });
this.fileSaver.saveBlob(blob, 'Test.txt');-