Skip to content

Instantly share code, notes, and snippets.

@bitflower
Forked from asafge/ng-really.js
Last active August 29, 2015 14:24
Show Gist options
  • Save bitflower/7f902e61511654bc7a59 to your computer and use it in GitHub Desktop.
Save bitflower/7f902e61511654bc7a59 to your computer and use it in GitHub Desktop.
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
if (message && confirm(message)) {
scope.$apply(attrs.ngReallyClick);
}
});
}
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment