nativescript-angular icon indicating copy to clipboard operation
nativescript-angular copied to clipboard

Issue related nested routing on BottomNavigation using RouterExtensions

Open semocodev opened this issue 7 years ago • 5 comments

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 6.2.0
  • Cross-platform modules:
  • tns-core-modules: 6.2.1
  • Android Runtime: 6.2.0
  • iOS Runtime: -
  • Plugin(s): -
  • NativeScript-Angular: 8.20.2
  • Angular: 8.2.11

Describe the bug Issue related nested routing on BottomNavigation using nativescript-angular

Navigation structure according this structure:

  • App-routing:
const routes: Routes = [
    { path: "welcome", component: WelcomeComponent },
    { path: "pages", loadChildren: () => import("./pages/pages.module").then(m => m.PagesModule) },
    { path: "", redirectTo: "welcome", pathMatch: "full" },
];
  • Pages-routing module
const routes: Routes = [
  {
    path: '',
    component: PagesComponent,
    children: [
      {
        path: 'home',
        outlet: 'homeoutlet',
        component: HomeComponent
      },
      {
        path: 'advices',
        outlet: 'advicesoutlet',
        component: AdvicesComponent
      },
      {
        path: 'alerts',
        outlet: 'alertsoutlet',
        component: AlertsComponent
      },
      { path: '', redirectTo: '/(homeoutlet:home//advicesoutlet:advices//alertsoutlet:alerts)', pathMatch: 'full' }
    ]
  }
];

When i am trying to navigate from /welcome route to pages/[path] route, this.routerExtensions.navigate([{ outlets: { homeoutlet: ['pages', 'home'] } }]); If I use relativeTo: this.activeRoute the result is the same.

i get this error: Error: ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'pages/home'

To Reproduce

Expected behavior

Sample project Playground example: https://play.nativescript.org/?template=play-ng&id=sVR895&v=6

Additional context

semocodev avatar Nov 14 '19 02:11 semocodev

@smorcuend sounds like an issue with passing the proper path - try enabling the Angular router tracing to see what happens behind the scenes.

imports: [NativeScriptRouterModule.forRoot(routes, { enableTracing: true })],

NickIliev avatar Nov 15 '19 13:11 NickIliev

:wave: @smorcuend, we use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please, use Stackoverflow to get help.

support avatar Nov 15 '19 13:11 support

Thanks you @NickIliev. I will test on a pure Angular app to find about navigation issues with outlets. Meanwhile, i am using https://github.com/Akylas/nativescript-material-components and it works perfectly.

semocodev avatar Nov 16 '19 11:11 semocodev

@smorcuend did you figure out a solution to this? been beating my head against the wall for 2 days. worst case is to pivot to react-native as there is bigger community support

ed-builds avatar Jul 19 '20 02:07 ed-builds

Hi. A possible workaround is to use visibilities and different components instead of the nested routing. Then you can just write a function that sets which component you want to see. I didn't use tabs or anything like that to select which component to "navigate" to. I made a custom navigation bar that looks like tabs. If you send a your code I can see if I can help you with that. Hope this helps.

On Sun, 19 Jul 2020, 4:24 am Edward Adjei [email protected] wrote:

@smorcuend https://github.com/smorcuend did you figure out a solution to this? been beating my head against the wall for 2 days. worst case is to pivot to react-native as there is bigger community support

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/NativeScript/nativescript-angular/issues/2072#issuecomment-660574455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNDDIGI7W7Y7N3U65SKFW3R4JKPPANCNFSM4JNEQUMQ .

Meyer-dev avatar Jul 20 '20 17:07 Meyer-dev