In my angular application i load dynamic background images from my backend.
Showing pictures is not a problem.
Background pictures are not loaded, unfortunately I don't get an error message.
my Angular version is 7.3.8.
I tried some solutions from stackoverflow and the web, but nothing help
Layout - html:
<div *ngIf="headerImage" [style.background-image]="headerImage">
Layout-Component:
ngOnInit() {<br/>
this.setup = this.route.snapshot.data['setup'];
this.createHeader(this.setup)
}
createHeader(setup: Setup){
const tempImage = 'data:image/png;base64,' + this.setup.headerImage.data;
this.headerImage = this.sanitizer.sanitize(SecurityContext.STYLE, 'url(' + tempImage + ')');
console.log(this.headerImage);
}
Output from my console:
this.headerImage console.log: url(data:image/png;base64,iVBORw0KGgo.......
I tried
[ngStyle]="{'background-image':' url(' + headerImage + ')'}"
and this
this.backgroundImg = sanitizer.bypassSecurityTrustStyle('url(....)'
But nothing works.
I don't know, what happen? I dont get a error messages and to show a Image is not a problem... but i need a background.
Thx for help!