how to download file with blob function using angular 5

Try the following code

saveAsBlob(data: Response){
  var blob = new Blob([data._body], { type: 'image/png' });
  var url= window.URL.createObjectURL(blob);
  window.open(url);
}

My solution to start a download. I used this in an NgRX Effect.

// ... getting blob form somewhere
const anchor = document.createElement('a');
anchor.download = "some_file_name.txt";
anchor.href = (window.webkitURL || window.URL).createObjectURL(blob);
anchor.click();

i got it like this it work with url:

download(row) {
    return this.Http
      .get(url, {
        responseType: ResponseContentType.Blob,
      })
      .map(res => {
        return {
          filename: row.name,
          data: res.blob()
        };
      })
      .subscribe(res => {
        let url = window.URL.createObjectURL(res.data);
        let a = document.createElement('a');
        document.body.appendChild(a);
        a.setAttribute('style', 'display: none');
        a.href = url;
        a.download = res.filename;
        a.click();
        window.URL.revokeObjectURL(url);
        a.remove();
      });
  }