Back button exits the app in Android even though we are navigating from a previous state

Using Ionic v1.0.1

The ionic app has a side menu of the following structure:

<ion-side-menus enable-menu-with-back-views ="true">
  <ion-side-menu-content class="has-subheader">
    <ion-nav-bar class="bar-positive">
      <ion-nav-buttons side="left">
        <button class="button button-icon button-clear ion-navicon" menu-toggle="left" >
      </ion-nav-buttons >

      <ion-nav-buttons side="right" >
        <button class="button button-icon button-clear ion-load-d fa-spin" ng-show= "isContentLoading">
      </ion-nav-buttons >
    </ion-nav-bar >

    <div class="bar bar-subheader " ng-class ="actionInfo.uiClass" ng-show="actionInfo.isVisible" >
      <h1 class="title">< i class ="icon" ng-class="actionInfo.msgIcon" ></i> {{actionInfo.msg}}</h1 >
    </div >
    <ion-nav-view name="menuContent"></ ion-nav-view>
  </ion-side-menu-content >

  <ion-side-menu side="left">
    <ion-nav-view cache-view= "false" name ="leftMenu"></ ion-nav-view>
  </ion-side-menu >

To navigate between different states and views, I’m currently using

   <ion-footer-bar class="bar-balanced" ng-click= "goToHome()" >
         <div class="title" >
              Proceed <i class="icon ion-ios-arrow-right" ></i>

in goToHome I’m navigating to a different state using

$state.go( _state_name_);

In this configuration the back button doesn’t seems to be working on android… On hitting the back button the app exits… It doesn’t navigate to the previous state/view…
On further debugging found that:
Its because of this code in ionic bundle .js

 function onHardwareBackButton(e) {
    var backView = $ionicHistory.backView();
    if (backView) {
      // there is a back view, go to it
    } else {
      // there is no back view, so close the app instead
    return false;

As per this code the history stack seems to be empty… Why should this happen?
How do I get the back button to function normally… I.e. go to the previous state… ?

1 Like

I have the same problem. If you comment those lines, code works well, It seem a priority problem.