I am using Ionic 4 and Angular 8 I have below tabs on the bottom of my app and want to navigate from forum and messages to different components associated with tabs on the click of tabs. But the issue is Page do not render on the click of tabs but if I refresh my page then navigation works fine. I don't know what I am missing here.
Tabs HTML
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button selected tab="food" (pointerup)="changeItems('food')">
<ion-icon name="pizza"></ion-icon>
<ion-label>Food</ion-label>
</ion-tab-button>
<ion-tab-button tab="non-food" (pointerup)="changeItems('non-food')">
<ion-icon name="basket"></ion-icon>
<ion-label>Non-Food</ion-label>
</ion-tab-button>
<ion-tab-button class="add-circle" tab="createListing" (pointerup)="routeTo('createListing')">
<ion-icon name="add-circle"></ion-icon>
</ion-tab-button>
<ion-tab-button tab="forum" (pointerup)="routeTo('forum')">
<ion-icon name="folder"></ion-icon>
<ion-label>Forum</ion-label>
</ion-tab-button>
<ion-tab-button tab="messages" (pointerup)="routeTo('messages')">
<ion-icon name="chatboxes"></ion-icon>
<ion-label>Messages</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
routesTo('messages') and routesTo('forum') in TS file.
routeTo(route: string){
this.navCtrl.navigateForward(`sharing/${route}`);
}
I have a login page inside LandingPageModule from where I directly route to 'sharing/home' which is a child route of 'sharing'
For more information I have base route module as:
const routes: Routes = [
{ path: '', redirectTo: 'landing', pathMatch: 'full' },
{ path: 'landing', loadChildren: () => import('./landing/landing.module').then(mod=> mod.LandingPageModule) },
{ path: 'sharing', loadChildren: () => import('./sharing/sharing.module').then(mod=> mod.SharingModule) }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }
Sharing module's routes are as:
RouterModule.forChild([
{
path: '',
component: ShareLayoutComponent,
children:[{
path: 'home',
component: HomeComponent
},
{
path: 'forum',
component: ForumComponent
},
{
path: 'messages',
component: MessageComponent
}]
}])