Disable sidemenu problem

I am trying to disable side menu. i am getting problem with it. it wont disable.

Hi,
I also got same problem.
I need to hide sidemenu in some views but i can’t.
It is working fine in older version of ionic.
Here’s my code:

.state('app', {
      url: "/app",
      abstract: true,
      templateUrl: "templates/menu.html",
      controller: 'AppCtrl'
    })

    .state('app.search', {
      url: "/search",
      views: {
        'menuContent' :{
          templateUrl: "templates/search.html"
        }
      }
    })

To Disable sidemenu in search page i change the code like this

.state('search', {
      url: "/search",
      templateUrl: "templates/search.html"
    })

It generating error in console… i have accessed the page as localhost:8100/#/search

This above change is working fine in previous version…

I think it’s the bug in newer version of ionic.

Thanks,
Lomas Joshi

It depends on your html structure ;).
Not only on the state structure.

If you want to disable sidebar only on a few states consider setting up a check, if state should show sidemenu - if not disable dragOnContent and hide your menu button :wink:

1 Like

Hi bengtler,
Thanks for your reply, but it create little problem. If i add
drag-content=“false” in <ion-pane ion-side-menu-content>
It disables the drag in every state. I need to perform this action on some specific state only.

PS: How can i hide the menu button? should i overwrite css or is there any method provided by ionic?

Thanks,
Lomas Joshi

You have to check your current state (everytime the state changes) and use http://ionicframework.com/docs/api/service/$ionicSideMenuDelegate/

to disable side navigation.

Dive into $scope.$watch to watch $state.current.name -> there you get the current state name.
If you want to disable side menu on this state then:
$ionicSideMenuDelegate.canDragContent(false) else true

To hide something there are things like ng-show and ng-if build in angular.
ng-show=“condition” hides content, if the condition is false.
ng-if=“condition” remove dom node completly if condition is false

Greets, bengtler

1 Like

I added a <ionic-scroll> which contains an img to my app, when i drag the img to left the sidemenu pop out. Now i set $ionicSideMenuDelegate.canDragContent(false) and it works well, thank you! :smile: