Skip to content

Instantly share code, notes, and snippets.

@wmbest2 wmbest2/example.html
Last active Dec 17, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.