I am having issues with my ion-back-button
under Ionic v5 with Capacitor and Angular.
I am trying to achieve the following: Tab1 has a button that navigates to Tab2.
Tab2 has a ion-back-button
in its tool-bar
that should navigate back to the previous page (In this case Tab1
) (In other cases for example to Tab3
). Otherwise fall back to a default TabHome
.
I am doing the routing to Tab2
via the navCtrl.navigateForward(/tabs/tab2)
method.
I also tried using the default angular router method router.navigateByUrl('/tabs/tab2')
.
When I dont set the defaultHref
attribute of the ion-back-button
then its not showing. If I set it it always routes back to the defaultHref
url, instead to the previous tab Tab1
.
I am using lazy loading this way:
routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'tab3',
loadChildren: () => import('./home/home.module').then(m => m.Tab3PageModule)
},
{
path: 'tab1',
loadChildren: () => import('./favorites/favorites.module').then( m => m.Tab1PageModule)
},
{
path: 'tab2/:id',
loadChildren: () => import('./listing/listing.module').then( m => m.Tab2PageModule)
}
],
},
{
path: '',
redirectTo: '/tabs/tab3',
pathMatch: 'full'
},
]