My button instantiation is here:
<button ng-hide="todo === 'add'" confirm-click ng-click="delete()">Delete</button>
My directive code is here:
(function(app) {
app.directive('confirmClick', function(){
return {
restrict: 'A',
priority: 1,
terminal: true,
link: function(scope, element, attr) {
var msg = attr.confirmationNeeded || "Really Delete?";
var clickAction = attr.ngClick;
element.bind('click', function() {
if(window.confirm(msg)){
scope.$apply(clickAction);
}
});
}
};
});
}(angular.module('case1')));
If I remove the directive from the button ng-hide works, if I include the directive it no longer works. I would assume that the $scope.todo variable is outside of scope when I include the directive, but I wonder how I can go about fixing this?