Callback for SideMenu Close?


#1

Is there a callback available for when a side menu is closed?

I’m using a multi-level navigation in a side bar and would like to return to the top level when closed.

I’m using the following at the moment and calling it on selection of a sub-nav element.

        function moveToRootWhenClosed() {
            if (!$ionicSideMenuDelegate.isOpenLeft()) {
                setToRoot();
            } else {
                $timeout(moveToRootWhenClosed, 500);
            }
        }

but I hate using timers like this. Is there an event?


#2

You can do this.

http://ionicframework.com/docs/api/service/$ionicSideMenuDelegate/

 $scope.$watch(function () {
    return $ionicSideMenuDelegate.isOpenLeft();
  },
     function (isOpen) {
    if (isOpen){
      console.log("open");
    }

  });

#3

Thank you sir!

Cleaned it up a bit, but I like this much better!