I am trying to create an easy wildcard popover when in angularJS. I already use AngularUI for many other components, so it seems like a natural choice.
I created an example in plnkr, but it is important that I can just add confirmation to a button like this ...
<button confirm="Are you sure you want to delete what ever" confirm-func="deleteThing()" confirm-placement="right" confirm-title="Are you sure?" class="btn btn-default">Delete? </button>
and it works and creates a popover with cancellation or confirmation using my own template. But I need to be able to go through what ever functions in the "confirm-func" attribute in order to be triggered when I click confirm. Whatever I do, I cannot get it to work. Here is my directive that extends the angular UI ...
angular.module('plunker', ['ui.bootstrap']).directive( 'confirmPopup', function () {
return {
restrict: 'A',
replace: true,
scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&', func: '&' },
templateUrl: 'confirmPopup.html',
link: function ($scope, element, attrs) {
$scope.confirm = function(){
$scope.func();
$scope.$parent.tt_isOpen = false;
}
$scope.cancel = function(){
$scope.$parent.tt_isOpen = false;
}
}
};
})
.directive( 'confirm', [ '$tooltip', function ($tooltip) {
return $tooltip( 'confirm', 'confirm', 'click' );
}]);
Plunkr example: http://plnkr.co/edit/W9BWMc3x5khuaMEL7lp1?p=preview