I'm facing an issue with my code where I am trying to find the innerText of a div and change it. However, when I click on the button to retrieve the innerText, it shows as undefined
.
<p #dviInner>
Start editing to see some magic happen :)
</p>
<button (click)="clickinDiv()">click</button>
Here is the TypeScript code causing the problem:
@ViewChild('dviInner',{static:false}) dviInner:ElementRef;
clickinDiv():void{
console.log(this.dviInner.nativeElement.innerHtml)
}
What could be causing this issue, and how can I solve it?