When the framework (0.9.20) includes a back button in the navigation bar automatically, how to you define a function to execute when it is clicked? One use case is to present a popup and ask the user about first saving unsaved data.
http://forum.ionicframework.com/t/how-to-handle-a-click-on-the-generated-back-button/582
This is how I am doing this :
<ion-nav-back-button></ion-nav-back-button>
is defined in my tabs.html<ion-nav-bar>
(…)
<ion-nav-back-button ng-click="cancel()">Cancel</ion-nav-back-button>
(…)
</ion-nav-bar>
3. and finally In the controller :
$scope.cancel = function () { // insert whatever you want to do; $ionicHistory.goBack();};