Can someone help me figure out why an alert() is being executed three times in this code snippet:
$scope.logout = function () {
$rootScope.auth.$logout();
$rootScope.$on('$firebaseSimpleLogin:logout', function(event) {
alert("Logged out"); // This shows up 3 times.
});
}
Yet, when I try a simpler approach, it only happens once:
$scope.logout = function () {
$rootScope.auth.$logout();
alert("Logged out"); // This ONLY appears once.
}
I understand that the second method is more direct; executing one line after the other. However, what if $logout fails and presents a successful operation message when it's actually not? That's why I'm using the $firebaseSimpleLogin:logout
event to handle errors properly. Unfortunately, it's not working as expected.
Any ideas on what could be causing this issue?