2016-11-24 153 views
1

我有离子1应用程序,我有文件夹模板(home.html,menu.html,about.html ..)。问题是在index.hmtl我有代码:离子导航

<body ng-app="starter"> 
    <ion-nav-view></ion-nav-view> 
</body> 

此代码在每个页面上运行离子导航。问题是如何从我想要导航的页面中删除导航?我试过hide-nav-bar =“true” - 这隐藏了导航,但我仍然可以用滑动打开它。 我app.js:

angular.module('starter', ['ionic', 'starter.controllers']) 

.run(function($ionicPlatform) { 
    $ionicPlatform.ready(function() { 
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard 
    // for form inputs) 
    if (window.cordova && window.cordova.plugins.Keyboard) { 
     cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); 
     cordova.plugins.Keyboard.disableScroll(true); 

    } 
    if (window.StatusBar) { 
     // org.apache.cordova.statusbar required 
     StatusBar.styleDefault(); 
    } 
    }); 
}) 

.config(function($stateProvider, $urlRouterProvider) { 
    $stateProvider 

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

    .state('app.home', { 
    url: '/home', 
    views: { 
     'menuContent': { 
     templateUrl: 'templates/home.html' 
     } 
    } 
    }); 
    // if none of the above states are matched, use this as the fallback 
    $urlRouterProvider.otherwise('/app/home'); 
}); 

Controler.js:

angular.module('starter.controllers', []) 

.controller('AppCtrl', function($scope, $ionicModal, $timeout) { 

    // With the new view caching in Ionic, Controllers are only called 
    // when they are recreated or on app start, instead of every page change. 
    // To listen for when this page is active (for example, to refresh data), 
    // listen for the $ionicView.enter event: 
    //$scope.$on('$ionicView.enter', function(e) { 
    //}); 

    // Form data for the login modal 
    $scope.loginData = {}; 

    // Create the login modal that we will use later 
    $ionicModal.fromTemplateUrl('templates/home.html', { 
    scope: $scope 
    }).then(function(modal) { 
    $scope.modal = modal; 
    }); 

    // Triggered in the login modal to close it 
    $scope.closeLogin = function() { 
    $scope.modal.hide(); 
    }; 

    // Open the login modal 
    $scope.login = function() { 
    $scope.modal.show(); 
    }; 

    // Perform the login action when the user submits the login form 
    $scope.doLogin = function() { 
    console.log('Doing login', $scope.loginData); 

    // Simulate a login delay. Remove this and replace with your login 
    // code if using a login system 
    $timeout(function() { 
     $scope.closeLogin(); 
    }, 1000); 
    }; 
}) 

.controller('PlaylistsCtrl', function($scope) { 
    $scope.playlists = [ 
    { title: 'Reggae', id: 1 }, 
    { title: 'Chill', id: 2 }, 
    { title: 'Dubstep', id: 3 }, 
    { title: 'Indie', id: 4 }, 
    { title: 'Rap', id: 5 }, 
    { title: 'Cowbell', id: 6 } 
    ]; 
}) 

.controller('PlaylistCtrl', function($scope, $stateParams) { 
}); 

回答

2

使用此代码在您的app.js在配置文件中的状态。

.config(function($stateProvider, $urlRouterProvider) { 
    $stateProvider 
    .state('home', { 
    url: '/home', 
    templateUrl: 'templates/home.html' 
    }) 
    .state('app', { 
    url: '/app', 
    abstract: true, 
    templateUrl: 'templates/menu.html', 
    controller: 'AppCtrl' 
    }) 
    $urlRouterProvider.otherwise('home'); 
});