Created
October 4, 2013 20:45
-
-
Save abusedmedia/6832428 to your computer and use it in GitHub Desktop.
Add touch event attribute directive for Angular.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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