Problem with Back button


#1

Hello
Is there any solution in angularjs to associate a function by clicking the physical button to go back? I have the problem of when I click the button, the application closes and does not go back. Any suggestion?


#2

Yes you can.
registerBackButtonAction(fn, priority)
https://ionicframework.com/docs/api/platform/Platform/


#3

Thank you, that worked. But now I have another “problem”, I did not want to disable the button on all pages. I wanted to leave the main page with the possibility of going back, closing the application


#4

You could add a condition in your override where you check it.


#5

Yes, but if I enter a page where the back button is locked, the rest of the application is always with the button locked. That is when it blocks once, it no longer unlocks. Thanks


#6

You just have to delete it when you leave by using ngdestroy
check this topic, it’s probably not your ionic version but it’s the same :


#7

Thank you, it worked