I want to create a directive for confirmation dialog, when I submit the form. The question I found here is similar, but it doesn't solve my issue:
<button confirm-ng-click="Reset password?" type="submit" class="md-primary">Reset</button>
And the JS:
(function () {
'use strict';
angular.module('haha', [])
.directive('confirmNgClick', [ConfirmNgClick]);
function ConfirmNgClick() {
return {
priority: -1,
restrict: 'A',
link: function (scope, element, attrs) {
element.bind('click', function (event) {
var message = attrs.confirmNgClick;
if (message && !confirm(message)) {
event.stopImmediatePropagation();
event.preventDefault();
}
})
}
}
}
})();
So, when I click button, the dialog doesn't show up. What am I missing?