Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

html download tag not working angular

// Angular Solution

//html
<button type="button" class="btn btn-sm btn-warning"
(click)="downloadArchiveFile(item.file_name, downloadSrc+item.url)">
Download
</button>

//typescript
import { HttpClient } from '@angular/common/http';
///
constructor(private http: HttpClient) {}
///  

downloadArchiveFile(name: string, url: string) {
 this.loader.start();
 this.http.get(url, { responseType: 'blob' })
 .subscribe((data: any) => {
   this.loader.stop();
   console.log(data);
   this.download(name, data);
  }, (error) => {
    this.loader.stop();
    this.toastr.error(error, "Something Went Wrong");
  });
}

download(name, blob) {
 let link = document.createElement("a");
 link.download = name;
 link.href = URL.createObjectURL(blob);
 link.click();
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: how to call a export constants in nodejs 
Typescript :: Template variables are read-only. 
Typescript :: create file object from url typescript 
Typescript :: average of two lists python 
Typescript :: jupyter notebook create table 
Typescript :: highlight styled components on vscode 
Typescript :: To list all tcp ports. 
Typescript :: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories. 
Typescript :: typescript infinite loop 
Typescript :: sort an arraylist of objects in java 
Typescript :: python convert a csv to a tsv 
Typescript :: typscript node-ts with nodemon 
Typescript :: mongodb match multiple nested 
Typescript :: android get digits from string 
Typescript :: React.ComponentProps<T 
Typescript :: typescript promise 
Typescript :: form reset typescript 
Typescript :: check if email exists firebase 
Typescript :: empty object typescript 
Typescript :: typescript clone object 
Typescript :: how can i add multiple arguments in discord,js 
Typescript :: print all objects linked list python 
Typescript :: replace element in array typescript 
Typescript :: react-excel-renderer typescript 
Typescript :: define typescript types 
Typescript :: property does not exist on type any typescript 
Typescript :: Angular import from local library 
Typescript :: get weights of a layer keras 
Typescript :: how to set date axes limits in matplotlib plot 
Typescript :: how to remove second square brackets in an array 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =