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 :: append scripts using jquery 
Typescript :: react router dom private route typescript 
Typescript :: react make multiple fetch requests one after another 
Typescript :: flutter firebase notification token 
Typescript :: google sheets add all numbers in a column with condition 
Typescript :: typescript gitignore 
Typescript :: check in Recat if an url is of image or video 
Typescript :: typescript object key enum 
Typescript :: linq check if exists in list 
Typescript :: change url param angular 
Typescript :: classes in typescript 
Typescript :: react typescript scss 
Typescript :: Accessing Java Array Elements using for Loop 
Typescript :: ionic scroll to item programmatically 
Typescript :: if image is broken show alternative image angular 
Typescript :: create plots with multiple dataframes python 
Typescript :: add correct host key in /root/.ssh/known_hosts to get rid of this message 
Typescript :: check already exists from non deleted rows laravel 
Typescript :: echarts cdn 
Typescript :: type casting in typescript 
Typescript :: Duplicate function implementation.ts(2393) 
Typescript :: enum in ts 
Typescript :: union types typescript 
Typescript :: react-excel-renderer nextjs error 
Typescript :: search an array of objects with specific object property value 
Typescript :: nuxt 3 postcss 
Typescript :: how to add multiple arguments in discord commands rewrite 
Typescript :: typescript make object optional 
Typescript :: sails.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies 
Typescript :: difference between scripted testing and exploratory testing 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =