import {saveAs} from 'file-saver'; downloadFileService(url,opts){ return this._http.get(url,opts,{ responseType : 'blob', headers:new HttpHeaders().append('Content-Type','application/json') }); } downloadFile(){ downloadFileService('url','options').subscribe((resp)=>{ saveAs(resp,'filename.txt') },(err)=>{ console.log('downloadFile erro',err); }) }