Ionic - Show side menu in all view except main page

5

Hi. I have a problem with Ionic's side menu. I need to display it on all but the first views.

I tried to put all the views with the side menu, and hide the menu button on the main page, but when you put hide on the button, it disappears in all views. So that did not work out.

Then I also tried to insert the side menu in all views, except the main page, but as the side menu is being created on page 2, the back-button does not appear to take back to the main page. When I inspected the element, I noticed that the back-button exists, but with a hide class I can not change. Does anyone know how to do this?

    
asked by anonymous 29.09.2016 / 15:35

3 answers

1

This documentation may help you: Ionic History

Use $ionicHistory.currentView() to see if you're on the main page if you're hiding the side-menu: Side-menu

    
29.11.2016 / 20:38
1

In practice you simply create a route for the menu and use it in the pages you want, for example:

(function() {
    'use strict';
    angular.module('testModule').config(router);
    router.$inject = ['$stateProvider', '$urlRouterProvider'];

    function router($stateProvider, $urlRouterProvider) {
        $stateProvider
            .state('menu', {
                url: '/menu',
                abstract: true,
                templateUrl: 'menu/menu.html',
                controller: 'menuController'
            }).state('menu.pageOne', {
                url: '/pageOne',
                views: {
                    'menuContent': {
                        templateUrl: 'pageOne/pageOne.html',
                        controller: 'pageOneController'
                    }
                }
            }).state('menu.pageTwo', {
                url: '/pageTwo',
                views: {
                    'menuContent': {
                        templateUrl: 'pageTwo/pageTwo.html',
                        controller: 'pageTwoController'
                    }
                }
            }).state('login', {
                url: '/login',
                templateUrl: 'login/login.html',
                controller: 'loginController'
            });

        $urlRouterProvider.otherwise('/login');
    }
})();

In this situation, for example the login page does not have the menu. So every time it is redirected to login screen the menu will not appear.

    
13.12.2016 / 20:50
1

In your view, use hide-nav-bar="true" as in the following example:

<ion-view title="Sua localização" hide-nav-bar="true">

    <ion-content padding="true" class="has-header" has-bouncing="true">

Regarding the back button, before calling another screen use:

$ionicHistory.nextViewOptions({
                disableBack: false,
                historyRoot: true
            });

            $ionicHistory.clearCache();
            $ionicHistory.clearHistory();

$state.go("a_sua_view_no_apps");
    
24.07.2017 / 02:04