question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: angular, cannot easily access router outlet inside of tabs

See original GitHub issue

Bug Report

Ionic version: [x] 4.9.0

Current behavior: When setting [swipeGesture]="false" on the main router outlet, swipe to go back will not be disabled for child outlets (ion-tabs).

Setting swipeBackEnabled: true in the import of IonicModule.forRoot also has no effect on routing based navigation

Expected behavior: –> A way to globally disable swipe to go back, as it is currently broken on iOS.

Steps to reproduce: See above.

Related code: No related code.

Other information: Due to #19293 , we have to disable swipe to go back. Because of the way tabs now work, we no longer define our own ion-router-outlet for each tab, and thus are not able to set [swipeGesture]=“false” for tabs.

Ionic info:

Ionic:

   Ionic CLI                     : 5.2.7 (C:\Users\xxx\AppData\Roaming\nvm\v10.16.3\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.9.0
   @angular-devkit/build-angular : 0.803.3
   @angular-devkit/schematics    : 8.3.3
   @angular/cli                  : 8.3.3
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms : not available
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.0.1, (and 13 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.8

System:

   Android SDK Tools : 26.1.1 (C:\Users\xxx\AppData\Local\Android\sdk)
   NodeJS            : v10.16.3 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
wilk-polarnycommented, Sep 12, 2019

As a workaround: One can query the ion-tab using the ViewChild decorator and manually access its underlying outlet:

this.tabElement.outlet.swipeGesture = false

0reactions
liamdebeasicommented, Feb 8, 2022

Thanks, I can confirm that this is a defect in how tabs in Ionic Angular were built. The problem here is <ion-tabs> automatically renders an <ion-router-outlet>, but you need to set swipeGesture="false" on that router outlet, not the root one. As a workaround in Angular, you can query for the router outlet in tabs and set swipeGesture="false" for now.

Note that this is not a problem in React or Vue because those versions of Ionic require you to explicitly pass in an instance of <ion-router-outlet>. This became the recommended approach in Ionic Vue 5.6.10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: angular, cannot easily access router outlet inside of tabs ...
The problem here is <ion-tabs> automatically renders an <ion-router-outlet> , but you need to set swipeGesture="false" on that router outlet, ...
Read more >
Router outlet inside a module not working with ngForm
I have a module which is loaded at /dashboard in my main app module, this module has its own router outlet with 3...
Read more >
Router tutorial: tour of heroes - Angular
This tutorial provides an extensive overview of the Angular router. In this tutorial, you build upon a basic router configuration to explore features...
Read more >
Router Guards • Angular - codecraft.tv
There is a bug in Angular version 2.1.0 where the canDeactivate function is not passed the future ActivatedRouteSnapshot or the future RouterStateSnapshot ....
Read more >
Angular Router: Child Routes, Auxiliary Routes, Master Detail
and if you navigate elsewhere you are going to get an error. But where do these components get displayed? Configuring a primary router...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found