Reloading states not working in ui-router? $state.reload

I need to refresh/reload the ui router states so that it’s not navigating back to old data. Can’t get this working.


I’m calling these inside the controller.

See this post about going back.

This about clearing histories:

I’m getting an error:Error: 'undefined' is not an object (evaluating '$ionicViewService.clearHistory')

The code is pretty much identical to the codepen. Except I’m using version 0.9.27 and not nightly.

.controller('myCtrl', function($scope, $stateParams, $ionicModal, $rootScope, $ionicViewService) {
    console.log($rootScope.$viewHistory.histories); //logs fine
    $ionicViewService.clearHistory(); //error

Is there something additional I’m missing to include? Dependancy, file?

That translates to I’m using exactly the same code but completely different
The nightly is heavily changed since 0.9.27

So $ionicViewService.clearHistory(); is only available in a future release and not available in the current release?

Ok, what can I use instead?

Actually, it works fine in 0.9.27. Navigate in the sample. Then come back to the home page. Click “Show History”. Then, click “Clear History”. You’ll see the difference.

$ionicViewService keep coming back as undefined and I cant figure out why. As mentioned in my previous post, am I missing an include somewhere? Do I need to declare a dependancy or additional file? Simply the variable $ionicViewService is undefined. (as there is nothing available, it’s empty, not defined).

So by code example please see my previous post also.

I can log or print $rootScope.$viewHistory.histories and it displays the object containing the various viewId’s and state names.

Is $ionicViewService only available when using tabbed pages? Is there an alternative to clearing the ui-state history?

Try this:

$state.go($state.current, {}, {reload: true});

Saw it in an SO post.

In addition to what @peterrobot mentioned, set the cache:false in the state provider.

as I use this solution the view gets reloaded but the side menu and header gets disappeared!