Reputation: 873
How to disable ng-click event in confirmation Popup Button 1[Screen-Shot]
Upvotes: 2
Views: 287
Reputation: 3135
You can create a direcftive like this one :
app.directive('ngConfirmClick', [
function(){
return {
link: function (scope, element, attr) {
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.confirmedClick;
element.bind('click',function (event) {
if ( window.confirm(msg) ) {
scope.$apply(clickAction);
}
});
}
};
}]);
You use it this way :
<button confirmed-click="YourFunction()" ng-confirm-click="Are you really sure you want to do this ?">Action</button>
Upvotes: 2