Skip to content

Instantly share code, notes, and snippets.

@evenchange4
Forked from asafge/ng-really.js
Created August 7, 2014 06:42
Show Gist options
  • Save evenchange4/5cb93fa6842f4ff90be1 to your computer and use it in GitHub Desktop.
Save evenchange4/5cb93fa6842f4ff90be1 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);
}
});
}
}
}]);
@evenchange4
Copy link
Author

<span class="badge bg-important delete-btn" style="float:right; cursor:pointer" ng-confirm ng-confirm-message="Are you sure?">Delete</span>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment