How to use $windows.history.back

In angular we can use $windows.history.back to back to previous view. How do it with ionic? I try $windows.history.back, but it doesn’t work

Sorry, but we haven’t entirely finalized the API for this yet. But what you can do is use the $ionicViewService to get the “backView”, then call “go” on the view.

var backView = $ionicViewService.getBackView();
backView.go();

We’ll be making this simpler and improving the documention as we move forward. You could also look into use the ionNavBackButton directive. Hope this helps.

4 Likes

Any ETA on the $ionicViewService documentation?? Seems like a much better option than $location.path(’/app’) …

UPDATED:
So $location.path(’/app/home’) is better done by $state.go(‘app.home’)

However, is $ionicViewService able to change the default animation? Instead of a slide left-right, a slide up-down?

Right now, I don’t think there is any documentation. Your best bet is reviewing the code:

https://github.com/driftyco/ionic/blob/master/js/angular/service/viewService.js

This entry shows some samples about using the $ionicViewService : Changing the back-button "url" / "back state"