I'm getting the error "Error: Cannot match any routes. URL Segment: 'admin-home/admin-fixtures' Error: Cannot match any routes. URL Segment: 'admin-home/admin-fixtures'" When I'm trying to route to page containing tabs
My home page is also a tabs page (generated originally from ionic) and thats the example I'm trying to follow.
Here is my code which I think is relevant. On 1 of my pages Login.mhtl I click a button which links me to admin-home which should be a page containing 3 tabs
this.router.navigateByUrl('admin-home');
Here is the code for my admin-home.html
<ion-header>
<ion-toolbar color="dark" class="ion-icon-toolbar">
<ion-buttons slot="start">
<ion-button (click)="goBack()"><ion-icon slot="icon-only"
name="arrow-back"></ion-icon></ion-button>
</ion-buttons>
<ion-title>Admin Home</ion-title>
<ion-buttons slot="end">
<ion-button (click)="logOut()">
<ion-icon slot="icon-only" name="log-out"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-tabs>
<ion-tab-bar slot="top">
<ion-tab-button tab="admin-fixtures">
<ion-label>Fixtures</ion-label>
</ion-tab-button>
<ion-tab-button tab="admin-players">
<ion-label>Players</ion-label>
</ion-tab-button>
<ion-tab-button tab="admin-admins">
<ion-label>Admins</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</ion-content>
And here is the admin-home.router.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AdminHomePage } from './admin-home.page';
const routes: Routes = [
{
path: 'admin-home',
component: AdminHomePage,
children: [
{ path: 'admin-fixtures', loadChildren: '../admin-fixtures/admin-fixtures.module#AdminFixturesPageModule'},
{ path: 'admin-players', loadChildren: '../admin-players/admin-players.module#AdminPlayersPageModule'},
{ path: 'admin-admins', loadChildren: '../admin-admins/admin-admins.module#AdminAdminsPageModule'},
]
},
{
path: '',
redirectTo: '/admin-home/admin-fixtures',
pathMatch: 'full'
}
];
@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [RouterModule]
})
export class AdminHomePageRoutingModule {}
Adding the admin-fixture.module.ts code
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { AdminFixturesPage } from './admin-fixtures.page';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
RouterModule.forChild([{ path: '', component: AdminFixturesPage }])
],
declarations: [AdminFixturesPage]
})
export class AdminFixturesPageModule {}
You are getting this error because you are trying to route with the wrong page URL.
*"Error: Cannot match any routes. URL Segment: 'admin-home/admin-fixtures' Error: Cannot match any routes. URL Segment: 'admin-home/admin-fixtures'"
OR
Change your code like this (code shown above). On behalf of (code shown below)
Maybe this will help you...