1

I work in Ionic 2 and I want to display a picture with variable, somethink like this :

<img src="data:{{user.file.type}};base64,{{user.file.content}}"/> 

But the picture isn't display on my bowser and I have this error in the chrome console : "WARNING: sanitizing unsafe URL value"

Howerver, when I put my file type and file content in hard code it's work. But I need to use variable.

Any idea ? :)

V. Pivet
  • 1,320
  • 3
  • 25
  • 57

1 Answers1

2

Not sure why this happens but it can be prevented by creating a binding to the src

<img [src]="'data:'+ user.file.type +';base64,'+ user.file.content "/>

Plunker demonstrating the effect

In case that for some reason you don't want to/can't click the URL:

enter image description here

Ivar Reukers
  • 7,560
  • 9
  • 56
  • 99