bug: IonRouterOutlet canGoBack() return always return false
See original GitHub issueBug Report
Ionic version:
[x] 4.6.1 / 4.6.2
Current behavior:
ActivatedRoute canGoBack() always return false
Expected behavior:
canGoBack() should return correctly
Steps to reproduce:
Related code:
insert short code snippets here
Other information:
Ionic info:
insert the output from ionic info here
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:17 (5 by maintainers)
Top Results From Across the Web
bug: IonRouterOutlet canGoBack() return always return false ...
canGoBack() can change and ngOnInit() is called once; ngOnInit() is called before the page is even part of the outlet and the transition...
Read more >Ionic Android Platform BackButton Issue
Bug Report Ionic version: [x] 4.6.1 / 4.6.2 Current behavior: ActivatedRoute canGoBack() always return false Expected behavior: canGoBack() ...
Read more >How to get canGoBack functionality in Ionic 5? - Stack Overflow
If set to false, then it means it is dynamic and not static, and router outlet should be static since its one of...
Read more >canGoBack always return false - Ionic Forum
hello all i have i ion-tabs page as a root page , and in my app.component.ts a i register a backbuttonAction for showing...
Read more >@ionic/core | Yarn - Package Manager
All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines. 6.3.10 (2022-12-07). Bug Fixes. datetime: ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I took a closer look at the problem and it seems that routerOutlet always fetches the next parent instance of
ion-router-outlet
from the respective page. So if we callrouterOutlet.canGoBack()
insideapp.component.ts
, the value would always befalse
becauseion-tabs
have their ownion-router-outlet
.Thats why using
this.routerOutlet.canGoBack()
inside childpages ofion-tabs
will return the correct boolean value.If you need to handle something globally (like using android hardware backbutton to exit app) you can use following snippet:
It’s important that you handle the logic inside
tabs.page.ts
since we use theViewchild
ofion-tabs
, which contains the outlet for tabbed pages.@derWebdesigner still returning always false