Skip to content

Instantly share code, notes, and snippets.

@abusedmedia
Created October 4, 2013 20:45
Show Gist options
  • Save abusedmedia/6832428 to your computer and use it in GitHub Desktop.
Save abusedmedia/6832428 to your computer and use it in GitHub Desktop.
Add touch event attribute directive for Angular.js
angular.module('myapp', [])
.directive('quickTouch', function($parse) {
return {
restrict: 'A',
link: function(scope, elm, attrs) {
var fn = $parse(attrs['quickTouch']);
$(elm).bind('touchend mousedown', function(evt) {
scope.$apply(function() {
fn(scope, {$event: evt});
evt.stopPropagation();
return false;
});
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment