0

I'm trying to listen to when ionic-side-menu are opened and closed. To do this I am attaching the $ionicView.enter and $ionicView.leave like so:

$scope.$on('$ionicView.leave', function(){
  console.log('leave called');
});

$scope.$on('$ionicView.enter', function(){
  console.log('enter called');
});

Using this code $ionicView.enter is called once when the app loads and never again when toggling the menu. $ionicView.leave also never gets called.

monokh
  • 1,970
  • 3
  • 22
  • 31

1 Answers1

1

You can use $ionicSideMenuDelegate.isOpen() to keep track of opening and closing of the side menu:

$scope.$watch(function() { return $ionicSideMenuDelegate.isOpen(); }, function(isOpen) {
    if (isOpen) {
        // Menu Opened
    }
    else {
        // Menu Closed
    }
});

Reference: https://github.com/driftyco/ionic/issues/1437

Avijit Gupta
  • 5,676
  • 3
  • 20
  • 35