I am trying to setup a confirmation dialog on an ng-click
using a custom angularjs directive:
app.directive(\'ngConfirmClick\', [
function()
You don't want to use terminal: false
since that's what's blocking the processing of inside the button. Instead, in your link
clear the attr.ngClick
to prevent the default behavior.
http://plnkr.co/edit/EySy8wpeQ02UHGPBAIvg?p=preview
app.directive('ngConfirmClick', [
function() {
return {
priority: 1,
link: function(scope, element, attr) {
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.ngClick;
attr.ngClick = "";
element.bind('click', function(event) {
if (window.confirm(msg)) {
scope.$eval(clickAction)
}
});
}
};
}
]);