This is an SVG Circle:
<svg viewBox="0 0 104 104">
<circle cx="52" cy="52" r="50" stroke="#003EFF" stroke-width="4" fill="#00FF98" />
</svg>
This Angular Project imports it like this:
import circle from './circle.svg';
And adds it to a div
element like this:
<div [innerHTML]="svg" style="width:400px"><div>
But it looks like Angular XSS protection is stripping the content. Is there a way to override this?
I tried the DomSanitizer
like this:
constructor(private sanitizer: DomSanitizer) {
this.trustedCircle = sanitizer.bypassSecurityTrustUrl(this.svg);
But no love.
I use Angular Material, comes in handy with this:
In the constructor:
Add the icon or image in
ngInit
:And then in your HTML:
Just fix it for you. You can try to see if it work