Watch Ionic menu(left or right)

5:38 PM

.directive('watchMenu', function($timeout, $ionicSideMenuDelegate, $ionicScrollDelegate, $rootScope) {
  return {
    restrict: 'A',
    link: function($scope, $element, $attr) {
      // Run in the next scope digest
      $timeout(function() {
        // Watch for changes to the openRatio which is a value between 0 and 1 that says how "open" the side menu is
       
        $scope.$watch(function() { 
          return $ionicSideMenuDelegate.isOpenRight();
          //return $ionicSideMenuDelegate.isOpenLeft();
        }, 
          function(ratio) {
            $scope.data=ratio;
            if( ratio == 1){
              $rootScope.$broadcast('rightMenu.open');
              $ionicScrollDelegate.$getByHandle('rightMenuScroll').scrollTop();
            }else{}

          });
      });
    }
  };

});

You Might Also Like

0 comments