Search This Blog

2023/09/02

How to get Inner Text of element in angular



Assume you have anchor element whose inner text you want to find on click of it

inside your html file

<a class="page-link" href="#" (click)="loadPaging($event.target)">{{page}} </a>

inside your typescript file you need function

loadPaging(eventtarget: any): void {
const anchor = eventtarget as HTMLElement;
this.currentPage = parseInt(anchor.innerText)
}

here this.currentPage has value of innerText of your anchor

No comments:

Post a Comment