Last active
September 2, 2016 02:24
-
-
Save carlosrymer/9862232 to your computer and use it in GitHub Desktop.
Fix event bubbling prevention issue with ngClick when using ngTouch on a mobile device
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
var mobileLinkClickModule = angular.module('ngTouchNgClickMobileLinks', []); | |
mobileLinkClickModule.directive("link", function (){ | |
return function($scope, element, attrs) | |
{ | |
// ngTouch prevents links from executing when an ng-click is present, so we need to trigger the link in those instances | |
if(Modernizr.touch && typeof attrs.ngClick !== 'undefined') | |
{ | |
element.on('touchend', function(){ | |
element[0].click(); | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment