I m using angular 14, Am tried to get an ID from HTML dom (Html component) in array form . Manually, I get Id from the HTML component in the TS file but dynamic or in the array is not conveying.
header.ts
toHome() {
const element = <HTMLElement>document.getElementById("home");
return element;
}
toservice() {
const element = <HTMLElement>document.getElementById("service");
return element;
}
tohowitwork() {
const element = <HTMLElement>document.getElementById("howitwork");
return element;
}
toabout() {
const element = <HTMLElement>document.getElementById("about");
return element;
}
Header.component.html
<li><a class="nav-link" (click)="toHome()" href="#homebanner">Home</a></li>
<li> <a class="nav-link" (click)="toservice()" href="#service">Service</a></li>
<li> <a class="nav-link" (click)="tohowitwork()" href="#howitwork">How it Works</a></li>