What is the best way to handle hardware back button in an angular app?

I’m referring to handling the back button from a feature’s root page. In Ionic V3 one could rely on the framework to handle this as the app would navigate the feature root page through the NavController.setRoot, which would not allow back navigation as the navigation stack is empty.

What is the best way to accomplish this Ionic V4 - angular?

Currently, I’m using the canDeactivate router guard coupled with router NavigationStart event to achieve this. Is this the only way? While this works, it’s a little tedious and not as easy as the NavController.setRoot.

Is there another way?

1 Like