Handling Hardware back button inside controller


#1

Hello, Iam having a requirement where, when user clicks on Hardware back button, I need to call some function inside my controller. I am having other controllers too. But I need fire on only some controllers. How to implement this?


#2
function onHardwareBackButton(e) {
    //Call your stuff here
}

$ionicPlatform.registerBackButtonAction(onHardwareBackButton, 100);

That worked for me :slight_smile:


#3

BUt this code will get called for each controller. I need to call only for a specific controller. Any ideas?


#4

Add that code to the specific controller you mentioned and add the code you need to call inside of it.

That means the code will ONLY be called in the controller in which it resides :slight_smile: