Skip to content

Instantly share code, notes, and snippets.

@darkmavis1980
Last active August 29, 2015 14:09
Show Gist options
  • Save darkmavis1980/3e1cd3620d6c0e4abe9b to your computer and use it in GitHub Desktop.
Save darkmavis1980/3e1cd3620d6c0e4abe9b to your computer and use it in GitHub Desktop.
Confirm before ng-Click
.directive('ngConfirmClick', [
function(){
return {
priority: -1,
restrict: 'A',
link: function(scope, element, attrs){
element.bind('click', function(e){
var message = attrs.ngConfirmClick;
if(message && !confirm(message)){
e.stopImmediatePropagation();
e.preventDefault();
}
});
}
}
}
])
/*
taken from here: http://stackoverflow.com/questions/18313576/confirmation-dialog-on-ng-click-angularjs
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment