Back button

How do you make a back button in Ionic framework? I know I can do something like $location.path(’/previous_view’); but what if you dont know what the previous url is?

I currently have

<button onclick="history.back(-1)" class="button button-icon icon ion-chevron-left"></button>

But it seems buggy on iphone - sometimes it goes 2 views back

1 Like

Check out this for an introduction for ionic navigation
http://ionicframework.com/docs/angularjs/controllers/view-state/

The nav bar calls this code to go back, you could write your button to call it as well
https://github.com/driftyco/ionic/blob/master/js/controllers/navController.js#L25

1 Like

And this as well:

$window.history.back()

1 Like