I am building my app in ionic framework and my login code initially was
AuthService.login(data.username, data.password).then(function(authenticated) {
$state.go('app.dashboard', {}, {reload: true});
}, function(err) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
But unlike what I expected, page didnt reload after login and still showed back button with no menu option. I now changed the code to
AuthService.login(data.username, data.password).then(function (data, status, headers, config) {
$state.go('app.dashboard').then(function() {
$window.location.reload(true);
});
}, function (err) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
Code I now have works well on some of the android mobiles but wont work well on some android mobiles(4.x versions).
What is the right way to reload after login?
I think its behaviour of html. following is my menu.html code
<ion-side-menus enable-menu-with-back-views="false">
<ion-side-menu-content>
<ion-nav-bar class="bar-dark">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-buttons side="right">
<button class="button button-icon button-clear ion-navicon" menu-toggle="right">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="right">
<ion-header-bar class="bar-dark">
<h1 class="title">Menu</h1>
</ion-header-bar>
<ion-content>
<ion-list>
<!-- content -->
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
Following is my app.js code
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app.profile', {
url: "/profile",
views: {
'menuContent': {
templateUrl: "templates/profile.html"
}
}
})
//more pages
;