using (click)="onSelect(hero)
, I can bind to click event of li
tag.
I can also bind to mouseover
event of li
tag.
But I can't bind to keydown
event of li
tag.
li
tag supports click,mouseover,keydown
propety, so I think I can use keydown
event(down arrow) to navigate to the next item in this list box.
Where is the official docs I can look for?
<div class = "body-container">
<ul class = "heroes">
<li *ngFor = "let hero of heroes" (click)="onSelect(hero)" (keydown)="onKeydown()" (mouseover)="onKeydown()" class="bl-list-item" [class.bl-list-item-checked]="hero === selectedHero">
<div class="guide-label">
<span style="width:50px" [class.fa-check]="hero === selectedHero" [class.li-fa-check]="hero === selectedHero"></span>
<div class="guide-code-column">{{hero.id}}</div>
<div class="guide-name-column">{{hero.name}}</div>
</div>
</li>
</ul>
</div>
export class SearchComponent {
heroes: Hero[] = [];
selectedHero: Hero;
constructor(private heroService: HeroService) { }
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes);
}
showDialog = false;
onSelect(hero: Hero): void {
this.selectedHero = hero;
}
onKeydown(): void {
console.log("onKeydown");
}
}