Skip to content

Instantly share code, notes, and snippets.

@wmbest2
Last active December 17, 2015 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmbest2/5572586 to your computer and use it in GitHub Desktop.
Save wmbest2/5572586 to your computer and use it in GitHub Desktop.
ctrl-click directive
<span ctrl-click="someFuncInMyController()">Hello World</span>
angular.module("Components", []).directive("ctrlClick", function() {
return {
restrict: 'A',
link: function($scope, element, attrs) {
element.unbind('click');
element.bind('click', function(e) {
if (e.metaKey) {
$scope.$apply(attrs['ctrlClick']);
} else {
$scope.$apply(attrs['ngClick']);
}
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment