How to trigger event before closing bootstrap modal on angularjs directive ,
angular.module('app').controller("myModal", function myModal($scope, $modalInstance) {
$scope.modalInstance = $modalInstance;
});
template
< div> My modal < /div>
and directive
angular.module('app').directive('mymodal',function( $rootScope ){
return{
restrict : 'E',
replace : true,
templateUrl :'mymodal.html',
scope :{
modalInstance :'='
},
link: function (scope, elem, attr) {
scope.modalInstance.result.then(function() {
console.log('close');
}, function() {
console.log('dimiss');
});
}
});
I want to have confirm message before closing modal after click on backdrop. call modal dialog from here
$scope.openModal = function() {
$scope.modalInstance = $modal.open({
animation: true,
template: '<mymodal modal-instance="modalInstance"></mymodal>',
controller: 'myModal',
backdrop: true,
keyboard: true,
});
}