Encountering a glitch with the back button being triggered multiple times.
While I'm in the "messages" $state, everything functions normally when hitting the back button.
var messageIsClosed = true;
$ionicPlatform.onHardwareBackButton(function(event){
event.stopPropagation();
handleBackButton();
})
var handleBackButton = function(){
if(messageIsClosed){
$state.go("dash");
} else {
messageIsClosed = false;
}
}
However, upon navigating to another $state (e.g., "dash") and then returning to "messages", pressing the back button causes the code above to execute twice. Subsequent returns to "messages" lead to an increasing number of runs - 3 times, then 4, and so on. The back button script adds one execution each time the "messages" view/controller is revisited.
This unexpected behavior has me puzzled.