Я получаю изображение в String64 в json из моего приложения Spring Boot.
html
<img id = "userImage" src = "{{ userImage }}"/>
Машинопись
import {Component, OnInit} from '@angular/core';
import {UserService} from "./services/user/user.service";
import {DomSanitizer} from "@angular/platform-browser";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
private user:any;
private userImage:any;
constructor(private userService:UserService, private sanitizer: DomSanitizer) {}
ngOnInit() {
//TODO hardcoded...
this.getUser("admin");
}
getUser(username) {
this.userService.getUser(username).subscribe(user => {
console.info(user);
this.user = user;
this.userImage = this.sanitizer.bypassSecurityTrustUrl("data:Image/*;base64," + user.image);
});
}
}
ОШИБКА:
core.js:7909 WARNING: sanitizing unsafe URL value SafeValue must use [property]=binding: data:Image/*;base64,/9j/4....
unsafe:data:image/*;base64,:1 GET unsafe:data:image/*;base64,



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Попробуй это:
<img id = "userImage" [src] = "userImage"/>
Если у вас все еще есть проблемы, убедитесь, что изображение, которое вы получаете из серверной части, является правильным.