I code some html
in my component like below. I add span
with specific class in renew innerHTML
of an element:
nodes = this.getAllTextnodes(this.textarea.nativeElement);
x1 = nodes[0].data.substring(0, this.characterLimit - 1);
x2 = nodes[0].data.substring(this.characterLimit - 1, nodes[0].nodeValue.length);
x3 = '';
for (let i = 1; i < nodes.length; i++) {
x3 += '<span class="highlighted-text">' + nodes[i].nodeValue + '</span>';
}
replaceContent = x1 + '<span class="highlighted-text">' + x2 + '</span>' + x3;
this.textarea.nativeElement.innerHTML = replaceContent;
but when my code run, my class did not apply to span. I get below photo to make this sense better:
and problem is here that i don't have _ngcontent_c10
in my span
, but i don't know how to fix this problem.