I have code that generates a random symbol svg but when I try to bind that svg as [innerHTML]
I get no results, but when I bind document.getElementById().innerHTML
my SVG displays as normal
holder : any
createSymbolIcon(): any {
//placeholder until get full list of icons
let symbolsSIDC = ['G*C*FS TP --*****', 'SUP*------*****', 'SNP*------*****']
var renderedContent = "";
for (var i = 1; i <= 10; i++) {
var sidc = symbolsSIDC[Math.floor(symbolsSIDC.length * Math.random())];
renderedContent = new ms.Symbol(sidc, { size: 30, infoFields: false }).asSVG();
if(angularBind){
this.holder = renderedContent
} else {
document.getElementById("symbols" + i).innerHTML = renderedContent;
}
}
}
}
Ignoring the loop and the holder var only holding the last element, here is what the binds look like in the HTML
<div id="symbols1" [innerHTML]='holder'></div>
Lastly, renderedContent
has an output similar to
"<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="35.4" height="38.4" viewBox="41 26 118 128"><path d="M 45,150 L 45,30,155,30,155,150" stroke-width="4" stroke="black" fill="rgb(170,255,170)" fill-opacity="1" ></path><path d="M45,50 l0,-20 110,0 0,20 z" stroke-width="4" stroke="none" fill="black" ></path></svg>"
Any idea what is causing this svg tag to not render when it is bound with the [innerHTML] value? I would prefer not using document.getID
Thanks!