Ionic 4 ionViewCanLeave functionality

Hi all,

I’m writing my app in Ionic 4 (angular + capacitor) and I want to control and allow/forbid going “back” from a sub-page based on some criteria (both using the back “soft” button or the hardware button).

I am new to Ionic so “google is my friend” :slight_smile: but all info I could find relate to Ionic 3 and the function “ionViewCanLeave()” which seems to not be available in Ionic 4.

Any ideas on how to do this?

Thanks for any hints :slight_smile:

I have not yet worked with guards but believe that this might be what you are looking for.

Have you find a solution? I tried with CanDeactivate guard but seems not working. If I navigate to another page with routerLink, CanDeactivate isn’t called