Ravi Shah
Ravi Shah

Reputation: 873

how to disable ng-click event in confirmation Popup Button

How to disable ng-click event in confirmation Popup Button 1[Screen-Shot]

Upvotes: 2

Views: 287

Answers (1)

IggY
IggY

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

Related Questions