i am trying to create a confirmation dialog in angularjs, i found an answered question about that in stackoverflow Confirmation dialog on ng-click - AngularJS i tried it as it is answered but when i click cancel it works as if i clicked OK is the answer wrong or should i add something else
<button type="button" ng-click="updateData()" ng-confirm-click="Are you sure?">
Update
</button>
directive
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.$eval(clickAction)
}
});
}
};
}])