Handling Hardware back button inside controller

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?

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

$ionicPlatform.registerBackButtonAction(onHardwareBackButton, 100);

That worked for me :slight_smile:

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

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: