When a user inputs text to search for an element in a list, I want the page to scroll to that specific element. However, I am having trouble obtaining the X,Y position of the element in the list. Here is my code:
<input type="text" (change)="search(event)">
<div *ngFor="let item from list">
{{item.lib}}
</div>
search(event:any){
let itemSearch = event.target.value;
this.list = this.list.filter((val)=>{
if(val.lib.indexOf(itemSearch)>=0){
let scrollY= val.lib.indexOf(itemSearch);
if(scrollY !==-1){
document.querySelector('.scroll')?.scroll (0,Scroll);
}
}
)};
This.list;
}