Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

html download tag not working

// 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 :: html download not working angular 
Typescript :: how to create dict key with list default -1 
Typescript :: godot preload 
Typescript :: lua operators 
Typescript :: ubuntu hosts file location 
Typescript :: pathmatch angular 
Typescript :: mongo count elements in array 
Typescript :: sample typescript code 
Typescript :: typescript endless loop 
Typescript :: how to separate elements in list python 
Typescript :: vertical dots latex 
Typescript :: material ui styled components with theme 
Typescript :: write a C proogram to find the roots of quadratic equation 
Typescript :: types date typescript 
Typescript :: how to sort numbers in typescript 
Typescript :: get elements in list in another list c# 
Typescript :: Emotion: Using both a class and the "css" method in "className" prop 
Typescript :: Cannot show Automatic Strong Passwords for app bundleID: com.williamyeung.gameofchats due to error: iCloud Keychain is disabled 
Typescript :: typerscript online compiler 
Typescript :: add active class when element exists into an array vuejs 
Typescript :: api service in angular 
Typescript :: using es6 set in typescript 
Typescript :: td elements in same line 
Typescript :: main.ts is missing from the typescript compilation 
Typescript :: learn typescript 
Typescript :: mixpanel for typescript 
Typescript :: comments visual studio code html 
Typescript :: use sample weights fit model multiclass 
Typescript :: from how many ways we can define props with typescript react 
Typescript :: how to check if a value exists in unorderedmaps 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =