Override Back Buton : the code is good but not activated at first start


#1

Hi All,

I creaded an application and I want to override the backbutton.
This code works but it is not actived when user start application.
User needs press “burger menu” one time to active the following code.
Can i have help, please ?

.run(function($ionicPlatform,$rootScope,$ionicSideMenuDelegate, $state, $window) {

      // Disable BACK button on home

      //alert('registerBackButtonAction !!!');
      $ionicPlatform.registerBackButtonAction(function (event) {
          //alert($state.current.name);
          event.preventDefault();
          if(($state.current.name!="app.winesDetail") && ($state.current.name!="app.ficheDetail")){
             $ionicSideMenuDelegate.toggleLeft();
          } else {
           navigator.app.backHistory();
          }
          //event.preventDefault();
          return false;
      }, 101);

      //$ionicSideMenuDelegate.toggleLeft();
      //$ionicSideMenuDelegate.toggleLeft();
      //angular.element('#menuBouton').trigger('click');

    });
})

#2

No idea ? :cry: :sob: