1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// service downloadFile(id: number): Observable<Blob>{ return this.http.get(`downloadurl` + id,{ responseType: 'blob' }); } //import in top of ts file import { saveAs } from 'file-saver'; // compoment function onClickDownload(id:any, fileName: string){ this.loader = true; this.Service.download(id).subscribe( ( blob: string | Blob) => saveAs(blob, '#'+fileName)); setTimeout(() => { this.loader = false; }, 2000); } |
Leave a reply