The issue we are having is when we listen for the event 'ngDialog.closed', we found that it is firing multiple times. We are only opening the dialog once, so we assume that closing the same modal, this event should only fire once as well. There are multiple modals across the application, and we listen for this specific modal by attaching it to $rootScope, like so:
$rootScope.$on('ngDialog.closed', function (e, $dialog) {
console.log("CLOSED TEHE MODAL", $dialog);
console.log("EVENT", e);
if($rootScope.modalFinished && localStorage.getItem("tourComplete") !== "true"){
$rootScope.modalFinished = false;
console.log("THIS IS LOCAL STORE:", localStorage.getItem("tourComplete"));
$scope.CallMe();
}
});
The reason we are listening via $rootScope is to pass this "closed" event from one controller(the modal) to another controller(home screen) that has already been loaded before the modal controller.
We have noticed that on the 'ngDialog.closed' event, multiple events are being fired (usually up to 2 to 3 times per closing of a modal).
Here is where we open the ngDialog (in the login controller):
$state.go('app.dashboard')
if(AclService.can('edit')|| AclService.can('admin')){
$scope.$on('$stateChangeSuccess', function onStateSuccess(event, toState, toParams, fromState){
$rootScope.modalFinished = true;
CauseService.get().then(function(result){
var cause = result[0].attributes;
if(!cause.has_backlinked || !cause.has_verified_address){
// $rootScope.modalFinished = true;
ngDialog.open({
template: '../../app/views/dashboard/progress_modal.html',
showClose: false,
className: 'ngdialog-theme-default progressModal',
controller: 'ProgressModalController',
resolve:{
'Cause': ['CauseService', function(CauseService){
// console.log("CauseService in routes", CauseService.get());
return CauseService.get();
}]
}
});
}
});
});
}
Any help would be greatly appreciated.
Thanks so much.
-M-