I need to display an image in Angular 7 from an API. I can retrieve the image either as form-data or by path of the image. So how do I display it in Angular?
I already tried to display an image using its file path but had no success. The code I tried is given below.
TS FILE
this.httpClient.get(`${this.url}`,this.httpOptions)
.subscribe(data => {
this.image=data['filePath'];
this.finalImage = this.sanitizer.bypassSecurityTrustUrl(this.image);
},
error => {
console.log(error);
}
);
HTML
<div> <img src="{{finalImage}}"> </div>
<div> <img [src]="finalImage"> </div>
<div> <img bind-src="finalImage"> </div>