I have html element like
<section class="" #hiddenElement>
<span>title</span>
<span class="value"></span>
</section>
I access the element in component using
@ViewChild('hiddenElement') hiddenElement: ElementRef;
How do i update the innerhtml of element whose class is value?
You can get hiddenElement
children using nativeElement.children
, filter them by className and modify their innerHTML using element.innerHTML
Something like this
Array
.from(this.hiddenElement.nativeElement.children)
.filter(c => c.className.includes('value'))
.forEach(c => c.innerHTML = 'New innerHTML');