I am developing mobile app with ionic framework.it has a side menu with following links
1.Home
1.Login
2.About
3.Settings
When user is logged in i want to change the login
in side menu to myprofile
link
In the login controller
.controller('LoginCtrl',function($scope,$http,$ionicPopup,$state){
$scope.login=function(user){
//http call for login api
//set the auth token
window.localStorage.setItem('usertoken',response.token);
$state.go('app.profile');
}
}})
In Menu controller
.controller('MenuCtrl', function($scope, $ionicModal, $timeout) {
//shows the login link when the user is not logged in othewise show profile.
if(window.localStorage.getItem('usertoken')==null){
$scope.showloginlink=true;
$scope.showprofilelink=false;
}else{
$scope.showloginlink=false;
$scope.showprofilelink=true;
}
});
Here is htmll
<ion-list >
<ion-item menu-close href="#/app/login" ng-show="showloginlink">
Login
</ion-item>
<ion-item menu-close href="#/app/profile" ng-show="showprofilelink">
Profile
</ion-item>
The problem it dosen’t show the profile link after login,but when i refresh the entire page it will works as i expected
How to solve this problem?
UPDATE
I have solved the problem via reload the state
$state.go('app.profile',null,{reload: true});
But i wil get another error,side menu is missing from my user_profilepage
I’ve added this enable-menu-with-back-views="true"
in menu.html
,but still i have the menu missing problem:(
Note:I am using ionic tabs template