I have recreated the problem using the starter template
Generate a new project based on tabs-template
ionic start ionic4demo tabs --type=angular
build the app and verify you can switch between tabs
generate 2 new pages
ionic generate page login
ionic generate page signup
Change app-routing.module, so the default page is login
const routes: Routes = [
{ path: ‘tabs’, loadChildren: ‘./tabs/tabs.module#TabsPageModule’ },
{ path: ‘’, loadChildren: ‘./login/login.module#LoginPageModule’ },
{ path: ‘signup’, loadChildren: ‘./signup/signup.module#SignupPageModule’ }
add this to login.page.html
<ion-button color=“primary” shape=“round” (click)=“login()”>log in</ion-button>
<ion-button color=“secondary” shape=“round” (click)=“signup()”>sign up</ion-button>
so the start page will be
add this in login.page.ts (adding NavController in the constructor)
login() {
this.navCtrl.goRoot(‘tabs’);
}
signup() {
this.navCtrl.goForward(‘signup’);
}
So basically just build an app with tabs, that require to login og signup before showing tabs as root
You should now have an app, where navigation to signup is fine, thus showing navigation is ok, but navigation to tabs fails.
I have tried:
this.navCtrl.goRoot('tabs');
this.navCtrl.goRoot('/tabs');
this.navCtrl.goRoot('tabs/(home:home)');
this.navCtrl.goRoot('/tabs/(home:home)');
each time getting the error
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ‘tabs’
Error: Cannot match any routes. URL Segment: ‘tabs’
So where am I going wrong?
Reading my topic before posting it, and checking the routes I realized, that the problem could be in tabs.router.module where I changed
path: '',
redirectTo: '/tabs/(home:home)',
pathMatch: 'full'
to
path: 'tabs',
redirectTo: '/tabs/(home:home)',
pathMatch: 'full'
and now I get the homepage shown, but not in the tabs layout.
Anyone got a working example?