Reputation: 571
I'm using the slide menu built in example in Ionic. When I redirect the to the home page from any page (with $location or $state.go), the menu is disabled. It cannot be displayed any longer.
$state.go('app.home');
$location.path('/#/app/home');
Any idea what's happening?
Here's the menu template
<ion-side-menus>
<ion-side-menu-content drag-content="true">
<ion-nav-bar class="bar-dark">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left">
<ion-header-bar class="bar-light">
<h1 class="title">Title</h1>
</ion-header-bar>
<ion-content>
<ion-list>
<ion-item menu-close href="#/app/login">
Login
</ion-item>
<ion-item menu-close href="#/app/account">
Account
</ion-item>
<ion-item menu-close href="#/app/logout">
Logout
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
And this is the config of the app
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html"
})
.state('app.home', {
url: "/home",
views: {
'menuContent@app': {
templateUrl: "modules/home/views/home.html",
controller: 'HomeCtrl'
}
}
});
$urlRouterProvider.otherwise('/app/home');
Upvotes: 1
Views: 2883
Reputation: 19
.state('login', {
url: "/login",
templateUrl: "templates/login.html",
controller: 'AppCtrl'
})
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl',
onEnter: function($state, Auth) {
if (!Auth.isLoggedIn()) {
$state.go('login');
}
}
})
.state('app.Propertylist', {
url: "/Propertylist",
views: {
'menuContent': {
templateUrl: "templates/Propertylist.html",
controller: 'PropertyCtrl',
onEnter: function($state, Auth) {
if (!Auth.isLoggedIn()) {
$state.go('login');
}
}
}
}
})`enter code here`
Upvotes: 0
Reputation: 571
answer here ionic slide menu don't appear when i use state.go in my controller
I forgot to use the option enable-menu-with-back-views="true"
on my <ion-side-menus>
Upvotes: 8