mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
IonicModule
|
|
|
|
.config(['$provide', function($provide) {
|
|
$provide.decorator('ngClickDirective', ['$delegate', function($delegate) {
|
|
// drop the default ngClick directive
|
|
$delegate.shift();
|
|
return $delegate;
|
|
}]);
|
|
}])
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
.factory('$ionicNgClick', ['$parse', function($parse) {
|
|
return function(scope, element, clickExpr) {
|
|
var clickHandler = angular.isFunction(clickExpr) ?
|
|
clickExpr :
|
|
$parse(clickExpr);
|
|
|
|
element.on('click', function(event) {
|
|
scope.$apply(function() {
|
|
clickHandler(scope, {$event: (event)});
|
|
});
|
|
});
|
|
|
|
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
|
|
// something else nearby.
|
|
element.onclick = function(event) { };
|
|
};
|
|
}])
|
|
|
|
.directive('ngClick', ['$ionicNgClick', function($ionicNgClick) {
|
|
return function(scope, element, attr) {
|
|
$ionicNgClick(scope, element, attr.ngClick);
|
|
};
|
|
}])
|
|
|
|
.directive('ionStopEvent', function() {
|
|
return {
|
|
restrict: 'A',
|
|
link: function(scope, element, attr) {
|
|
element.bind(attr.ionStopEvent, eventStopPropagation);
|
|
}
|
|
};
|
|
});
|
|
function eventStopPropagation(e) {
|
|
e.stopPropagation();
|
|
}
|