I am developing this Ionic/Cordova App where I have to do a reload after $state.go. I am doing it like this
$state.go('app.menu', {}, {reload: true}).then(function(){
$window.location.reload(true);
});
The above code works perfectly fine on a browser, the problem appears when I load it onto an iPhone simulator. The problem is it doesn't go to the specified state i.e app.menu
.
But if I remove the $window.location.reload(true);
, it does go the state.
What do you think is the problem?
Edit: If I add a timeout it works, but I don't want that. Like so
$state.go('app.menu', {}, {reload: false}).then(function(){
setTimeout(function() {
$window.location.reload(true);
}, 500);
})
This worked for me: Source Here.
By design, the views are cached. Try cache: false in your state.
$stateProvider.state('myState', {
cache: false,
url : '/myUrl',
templateUrl : 'my-template.html'
})
Use $timout without delay. It works for me.
$timeout(function() {
$window.location.reload(true);
});