我有一个应该捕获keyup事件的谷歌地图。我的组件是Google地图div的父级。它适用于Chrome,它不适用于Firefox或IE(未经测试wtith Edge)。Keyup事件没有被Angular 2捕获@HostListener
我的组件:
@Component({
selector: 'dashboard',
templateUrl: 'dashboard.component.html',
styleUrls: ['dashboard.component.css'],
host: {
'[attr.tabindex]': '-1'
},
providers: []
})
export class DashboardComponent implements OnInit{
/* some functions and other stuff here
* ...
*/
@HostListener('keyup', ['$event']) keyup(e) {
console.log('This will be called with Chrome, not with the others.');
}
};
你所经历的一样吗? (告诉我你是否需要更多信息)。 感谢
[编辑]
我试着用ElementRef和设置我的事件处理程序elementRef.nativeElement
的onkeyup
财产捕捉keyup
事件,没有运气
不幸的是,这是行不通的。我加了'tabindex =“ - 1”'。它仍然适用于Chrome。 –