Android back button - code


#1

Hi Ionic Folks ! ,

I’m really struck at the android back functionality. If anyone could post a demo on codepen , it would be helpful .

Even if thats listed under the docs it will be helpful for the beginners…

Cheers , So far loving the ionicframework


#2

You could do something like this

.controller('MyCtrl', function($scope, $ionicPlatform) {
   $ionicPlatform.onHardwareBackButton( function(){
    // Your function here
   })

   //or 


$ionicPlatform.registerBackButtonAction(function () {
  if (condition) {
    navigator.app.exitApp();
  } else {
    handle back action!
  }
}, 100)
    });

Check out the docs.

http://ionicframework.com/docs/api/service/$ionicPlatform/


#3

thanks ill try it out and let you know


#4

no luck my friend ! I tried it . Still it works similar to browser history.


#5

Hi Mike , it worked at last . Thanks for the input guys .

I wanted to check this out in windowsphone , if it works hurray!!!

Cheers Guys ! loving Ionic