![](/img/trans.png)
[英]Current selected value in angular6 material mat-selection-list
[英]Detect keyboard navigation in angular material mat-selection-list
使用键盘箭头在项目之间导航时,我想采取一些措施。
我应该执行任何事件吗? 通过单击ENTER可以触发selectionChange,但是我想在通过箭头导航时激活该功能。
<mat-selection-list #list (selectionChange)="selectionChange($event, list.selectedOptions)">
<mat-list-option (mouseenter)="showEditIcon(true, i)" (mouseleave)="showEditIcon(false, i)"
*ngFor="let lotItem of lotList; let i = index;"
(click)="showLotDetails(lotItem, i)"
[value]='lotItem'>
您可以在mat-selection-list
上使用keydown
键盘事件来调用selectionChange()
方法。 您需要同时添加(keydown.arrowup)
和(keydown.arrowdown)
事件处理程序。
<mat-selection-list #list
(selectionChange)="selectionChange($event, list.selectedOptions)"
(keydown.arrowup)="selectionChange($event)"
(keydown.arrowdown)="selectionChange($event)">
<mat-list-option (mouseenter)="showEditIcon(true, i)" (mouseleave)="showEditIcon(false, i)"
*ngFor="let lotItem of lotList; let i = index;"
(click)="showLotDetails(lotItem, i)"
[value]='lotItem'>
这是一个StackBlitz演示 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.