var app = angular.module('plunker', []);
app.controller('ParentCtrl', function($scope) {
$scope.fooCalled = 0;
$scope.foo = function() {
$scope.fooCalled++;
};
});
app.directive('ngConfirmClick', [
function(){
return {
priority: 100,
restrict: 'A',
//terminal: true,
link: function(scope, element, attrs){
element.bind('click', function(e){
var message = attrs.ngConfirmClick;
if(message && !confirm(message)){
e.stopImmediatePropagation();
e.preventDefault();
}
});
}
}
}
]);
<!doctype html>
<html ng-app="plunker" >
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<link rel="stylesheet" href="style.css">
<script>document.write("<base href=\"" + document.location + "\" />");</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-controller="ParentCtrl">
Foo Called: {{fooCalled}}<br/>
<button ng-click="foo()" ng-confirm-click="again">Call From Parent</button><br/>
</div>
</body>
</html>
/* Put your css in here */