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() { } }