usauae Posted June 18, 2021 Report Posted June 18, 2021 bros, naaku oka list item vundi, which has hundreds of names sorted alphabetically(source API). requirement: if I type 'F' on my keyboard, the list should scroll lo the names starting with F. yevaru aina ilantidi chesara ? can you please help me https://stackblitz.com/edit/angular-lrsztw?file=src/app/app.component.html Quote
usauae Posted June 18, 2021 Author Report Posted June 18, 2021 Keyboard event anta ready chesa but not sure how to make the list scroll. Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 38 minutes ago, usauae said: bros, naaku oka list item vundi, which has hundreds of names sorted alphabetically(source API). requirement: if I type 'F' on my keyboard, the list should scroll lo the names starting with F. yevaru aina ilantidi chesara ? can you please help me https://stackblitz.com/edit/angular-lrsztw?file=src/app/app.component.html knchm jquery vaadu broo... window keyup event listen cheyyali hostlisner all the time then fire event use jquery or javascript to move specific ID Quote
usauae Posted June 18, 2021 Author Report Posted June 18, 2021 17 minutes ago, kittaya said: knchm jquery vaadu broo... window keyup event listen cheyyali hostlisner all the time then fire event use jquery or javascript to move specific ID $(this)[0].scrollIntoView(); ila antava bro ? Quote
Kootami Posted June 18, 2021 Report Posted June 18, 2021 1 hour ago, usauae said: bros, naaku oka list item vundi, which has hundreds of names sorted alphabetically(source API). requirement: if I type 'F' on my keyboard, the list should scroll lo the names starting with F. yevaru aina ilantidi chesara ? can you please help me https://stackblitz.com/edit/angular-lrsztw?file=src/app/app.component.html 'f' names thos list filter avvala ? public InputText = new Subject<any>(); ngonit { this.inputText$.subscribe((inputLetter:any)=>{ this.inputList= this.inputList.filter(x=>x.name.contains(inputLetter); } } Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 https://stackblitz.com/edit/angular-bcuv45?file=src/app/app.component.ts done Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 import { Component } from '@angular/core'; import { fromEvent } from 'rxjs'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { name = 'Angular'; items: any[] = [ { name: 'A Sachin' }, { name: 'B Sachin' }, { name: 'C Sachin' }, { name: 'D Sachin' }, { name: 'E Sachin' }, { name: 'F Sachin' }, { name: 'G Sachin' }, { name: 'H Sachin' }, { name: 'I Sachin' }, { name: 'J Sachin' }, { name: 'K Sachin' }, { name: 'L Sachin' } ]; idList = []; getId(val, i) { this.idList.push(val.split(' ')[0] + i); return val.split(' ')[0]; } getrespectiveId(key) { return this.idList[ this.idList.findIndex( val => val.split('')[0].toLowerCase() == key.toLowerCase() ) ]; } constructor() { fromEvent(window, 'keydown').subscribe((event: KeyboardEvent) => { console.log(event.key); console.log(this.getrespectiveId(event.key)); document.getElementById(this.getrespectiveId(event.key)).scrollIntoView({ behavior: 'smooth' }); }); } } Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 <hello name="{{ name }}"></hello> <p> Start editing to see some magic happen :) </p> <div class="container border" style="height: 100px; overflow: auto;"> <ul style="list-style : none"> <li *ngFor="let item of items;index as i"><span id="{{getId(item.name, i)+ i}}">{{item.name}}</span></li> </ul> </div> Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 removed some glitch here https://stackblitz.com/edit/angular-bcuv45?file=src/app/app.component.ts Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 8 minutes ago, usauae said: $(this)[0].scrollIntoView(); ila antava bro ? solution here https://stackblitz.com/edit/angular-bcuv45?file=src/app/app.component.ts Quote
usauae Posted June 18, 2021 Author Report Posted June 18, 2021 24 minutes ago, kittaya said: solution here https://stackblitz.com/edit/angular-bcuv45?file=src/app/app.component.ts super bro stackblitz lo work avutundi, but not on my page. may be because there are more than one list on the page. chustunna easy ga yemi aina fix cheyavachhu yemo ani Quote
kittaya Posted June 18, 2021 Report Posted June 18, 2021 5 minutes ago, usauae said: super bro stackblitz lo work avutundi, but not on my page. may be because there are more than one list on the page. chustunna easy ga yemi aina fix cheyavachhu yemo ani Cool bro Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.