简体   繁体   English

在AngularJS中,如何监听单击事件,而不是触摸事件?

[英]How can you listen for a click event, but NOT a touch event in AngularJS?

I have an application where I have "cards" representing items in the store. 我有一个应用程序,其中有代表商店中商品的“卡片”。 On a device with a mouse (desktop, laptop) I have a hover event that shows a few more details, and presents a button to click. 在使用鼠标的设备(台式机,笔记本电脑)上,我有一个悬停事件,它显示更多详细信息,并提供一个单击按钮。 The whole card can be clicked, however, to go to that item's detail page. 可以单击整个卡片,然后转到该项目的详细信息页面。 On a touch-enabled device, however, there is no way to show that hover state. 但是,在启用触摸的设备上,无法显示该悬停状态。 Is there a way in angular's click event to determine if the event originated as a touch event so that I can disable the click action? angular的click事件中是否可以确定该事件是否起源于触摸事件,从而可以禁用click操作?

you should be able to check the event in your bind directly: 您应该可以直接在绑定中检查事件:

if(event.touches){
    //touchy
}
else{
    //no touchy
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM