Skip to content

Commit 3301822

Browse files
author
Caleb Amsden
committed
fix(ngTouch): allow use of href and ng-click with ng-touch
changes browser url on elements with ng-click if element has an href attribute fixes angular#5307
1 parent 0827e88 commit 3301822

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ngTouch/directive/ngClick.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ ngTouch.config(['$provide', function($provide) {
4848
}]);
4949
}]);
5050

51-
ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
52-
function($parse, $timeout, $rootElement) {
51+
ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement', '$location',
52+
function($parse, $timeout, $rootElement, $location) {
5353
var TAP_DURATION = 750; // Shorter than 750ms is a tap, longer is a taphold or drag.
5454
var MOVE_TOLERANCE = 12; // 12px seems to work in most mobile browsers.
5555
var PREVENT_DURATION = 2500; // 2.5 seconds maximum from preventGhostClick call to click
@@ -262,6 +262,11 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
262262
if (!angular.isDefined(attr.disabled) || attr.disabled === false) {
263263
element.triggerHandler('click', [event]);
264264
}
265+
266+
// If the element has an href attribute, ensure that the url gets updated.
267+
if (angular.isString(attr.href)) {
268+
$location.url(attr.href);
269+
}
265270
}
266271

267272
resetState();
@@ -293,4 +298,3 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
293298

294299
};
295300
}]);
296-

0 commit comments

Comments
 (0)