The below code is detecting click
in desktop but in mobile the touch
event gets triggered when trying to scroll over the element,how to prevent this touch
event and only detect tap
events.I am not allowed to use ng-touch
or ng-click
.
I have tried the below approaches but these dont seem to work.What changes need to be made in below code?
What's the best way to detect a 'touch screen' device using JavaScript?
onClick not working on mobile (touch)
What is the most reliable way to detect clicks (or touches) on both desktop and mobile devices?
(function() {
'user strict';
angular.module('myModule').directive('myDirective',function(){
return{
restrict:'A',
scope:{
id: '=myId',
pm: '=myPm'
},
link:function(scope,element,attrs){
element.on('click touchend',funtion(event){
console.log("clicked");
});
}
}:
});
}());