Is there a way to download HTML files into a local folder using Angular?
I attempted the following approach:
readFile(file: File) {
var reader = new FileReader();
reader.onload = () => {
console.log(reader.result);
};
reader.readAsText(file);
}
download(){
this.file= "../monFichier/file.html"
this.zip.file("file.yaml", this.readFile(this.file));
this.fileUrl = this.zip.generateAsync({type:"blob"}).then(function (blob) { // 1) generate the zip file
FileSaver.saveAs(blob, "downloadables.zip"); // 2) trigger the download
}, function (err) {
console.log('err: '+ err);
});
}
The issue arises from the code within this.readFile(file) because the property 'file' is not of type File. How can I access and read the content of this file in order to include it in the zip file?