I have a component which html structure look like:
<img mat-card-sm-image src="{{img}}" />
and in typescript
constructor(private loginService: LoginService) {
this.img = null;
this.loadImage();
}
loadImage = function () {
this.img = this.loginService.loginImg();
}
and login service:
loginImg() {
const url = "http://localhost:59078/api/image/login";
this.http.get(url, { responseType: 'blob' }).subscribe(result => {
console.log(result);
return result;
});
}
and the API Core controller
[HttpGet]
[AllowAnonymous]
[Produces("image/png")]
public IActionResult Login()
{
var file = Path.Combine(Directory.GetCurrentDirectory(),
"wwwroot", "images", "login.png");
return PhysicalFile(file, "image/png");
}
The idea that the image is not loaded... Why ?