Side menu scroll to top every time it opens


#1

Is there an easy way to do this? I assume just use the $ionicScrollDelegate but can I register that to call every time the menu opens?


#2

Yup, totally posible…

.controller('MainCtrl', function($scope, $ionicSideMenuDelegate, $timeout,  $ionicScrollDelegate) {

  $timeout(function () {


    $scope.$watch(function () {
      return $ionicSideMenuDelegate.getOpenRatio();
    },
                 
      function(ratio){
        if (ratio == 0 ){
          $ionicScrollDelegate.$getByHandle('my-handle').scrollTop();
        }
        else{}
      });
  });

})

#3

Thank you for sharing this. Saved a lot of time…