LordZardeck
LordZardeck

Reputation: 8283

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?

Upvotes: 1

Views: 88

Answers (1)

Mathew Berg
Mathew Berg

Reputation: 28750

you should be able to check the event in your bind directly:

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

Upvotes: 1

Related Questions