0

I'm trying to work on tabs, but the function for tabs calls it twice on first load(init).

Function in pages of tab1 loads twice - ionic-v4. After calling navigateByUrl the function on ngOnInit loads twice after I logged in.

this.router.navigateByUrl(’/tabs/tab1’); this is my tabs-router.module code below:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';

const routes: Routes = [
  {
    path: 'tabs',
    component: TabsPage,
    children: [
      {
        path: 'tab1',
        children: [
          {
            path: '',
            loadChildren: '../tab1/tab1.module#Tab1PageModule'
          }
        ]
      },
      {
        path: 'tab2',
        children: [
          {
            path: '',
            loadChildren: '../tab2/tab2.module#Tab2PageModule'
          }
        ]
      },
      {
        path: 'tab3',
        children: [
          {
            path: '',
            loadChildren: '../tab3/tab3.module#Tab3PageModule'
          }
        ]
      }
      // {
      //   path: '',
      //   redirectTo: '/tabs/tab1',
      //   pathMatch: 'full'
      // }
    ]
  },
  {
    path: 'responders',
    component: TabsPage,
    children: [
      {
        path: 'feed',
        children: [
          {
            path: '',
            loadChildren: '../feed/feed.module#FeedPageModule'
          }
        ]
      },
      {
        path: 'reported',
        children: [
          {
            path: '',
            loadChildren: '../reported/reported.module#ReportedPageModule'
          }
        ]
      },
      {
        path: 'reports',
        children: [
          {
            path: '',
            loadChildren: '../reports/reports/reports.module#ReportsPageModule'
          }
        ]
      },
      {
        path: 'waitingforapproval',
        children: [
          {
            path: '',
            loadChildren: '../modals/responderswaitinglist/responderswaitinglist.module#ResponderswaitinglistPageModule'
          }
        ]
      }
    ]
  },
  {
    path: '',
    redirectTo: '/login',
    pathMatch: 'full'
  }
];

@NgModule({
  imports: [
    RouterModule.forChild(routes)
  ],
  exports: [RouterModule]
})

export class TabsPageRoutingModule { }

Sudarshana Dayananda
  • 5,165
  • 2
  • 23
  • 45
Sheng
  • 31
  • 5

0 Answers0