I am trying to convert a base64 string to <img src='data:image/png;base64,${Here}' .
But always, when I try to display it, ng2 sanitizes my base64 string before rendering, it adds something to my value before showing it in the DOM. I found a workaround (using DomSanitizer), but it does not work in recent versions.
Here is my markup:
<img alt="RegularImage" src="data:image/png;base64,{{imgBase64}}">
And here is my component:
imgBase64="SomeBase64StringFetchedSomehow";
But angular2 appears in the next console message - WARNING: sanitizing unsafe URL value
How to prevent NG2 from disinfecting my base64 string?
Update
get getImg() { return this._sanitizer.sanitize(SecurityContext.URL,`data:image/png;base64,${this.img}`); }
Does not resolve this issue. DomSanitizer class no longer exists in RC6
source share