You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sup_File/src/app/download-link/download-link.component.ts

41 lines
1.1 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-download-link',
templateUrl: './download-link.component.html',
styleUrls: ['./download-link.component.scss']
})
export class DownloadLinkComponent implements OnInit {
idFile: String;
urlFile: String;
file: any;
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute) {
this.idFile = '';
this.urlFile = '';
this.route.params.subscribe(params => {
this.idFile = params['id'];
this.urlFile = 'http://localhost:3000/' + this.idFile;
console.log('this.idFile : ' + this.idFile );
this.http.post('/api/getFileById', {id: this.idFile.toString()}).subscribe(file => {
if (file) {
this.file = file[0];
console.log(this.file)
} else {
this.file = [];
}
});
});
}
ngOnInit() {
}
}