@eldy wrote:
Below is my sidebar (menu) controller. This work if a token existed in localstorage and I click logout. The view did get updated, I uses loggedIn for my ng-show in view.
.controller('AppCtrl', function($scope, $ionicModal,$window, $timeout,$ionicHistory,$state,$rootScope) { var token = JSON.parse(localStorage.getItem('token')); if(token){ $rootScope.loggedIn = true; }else{ $rootScope.loggedIn = false; } $scope.logout = function(){ localStorage.removeItem('token'); $ionicHistory.clearCache().then(function() { $rootScope.loggedIn = false; $ionicHistory.clearHistory(); $ionicHistory.nextViewOptions({ disableBack: true, historyRoot: true }); $state.go('app.shop'); }) } })
My problem is in my login controller
.controller('signupLoginCtrl', function($scope, $http, jwtHelper, $location, $ionicHistory, $state) {
$scope.doLogin = function(email, password) {
$http({
method: 'POST',
url: 'myurl.com/login',
skipAuthorization: true,
headers: {
'owner': $rootScope.secret
},
data: {
email: email,
password: password
}
}).then(function successCallback(response) {
if (response.data.success == true) {var tokenPayload = jwtHelper.decodeToken(response.data.msg); localStorage.setItem('token', JSON.stringify(tokenPayload)); $ionicHistory.clearCache().then(function() { $ionicHistory.clearHistory(); $ionicHistory.nextViewOptions({ disableBack: true, historyRoot: true }); $state.go('app.profile'); $rootScope.loggedIn = true; }) } else { alert(response.data.msg); } }, function errorCallback(response) { alert(response.data) }); }
The sidemenu view isn't get updated, any clue? I even tried hard refresh like
$state.go('app.profile',{},{reload:true})
andwindow.location = '#/app/profile'
Posts: 1
Participants: 1