I'm trying to put a back button in Ionic app and to hide the back button when it's in the root, which the root is not fixed and can be changed based on the flow. I found the following code here:
...
constructor(
private router: Router,
private ionRouterOutlet: IonRouterOutlet
) {
}
ngOnInit() {
this.canGoBack = this.ionRouterOutlet.canGoBack();
...
It would be nice if it works but IonRouterOutlet is component and cannot be injected to another component like this. Any idea about how can it be done in Ionic 5 with angular?
@ViewChild(IonRouterOutlet, { static : true }) routerOutlet: IonRouterOutlet;
// if (this.routerOutlet.canGoBack()) or whatevet...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With