Reputation: 845
In my routes,Created child components and I can see the default child route in the router outlet.But when navigate to the other child routes ,shows error "cannot match any routes".
routing.ts
const appRoutes: Routes = [
{
path: '',
component: HomeComponent
},
{
path: 'dashboard',
pathMatch: 'full',
component: DashboardComponent,
canActivate: [AuthGuard],
children: [
{
path: '',
pathMatch: 'full',
component: DashboardhomeComponent
} ,
{
path: 'profile',
pathMatch: 'full',
component: ProfileComponent
}
]
},
{
path: 'login',
component: LoginComponent
},
];
dashboard.ts
goto() {
this.router.navigate(['dashboard/profile']);
}
Upvotes: 1
Views: 929
Reputation: 222722
Try
this.router.navigate(['/dashboard/profile']);
and change your route as,
const appRoutes: Routes = [
{
path: '',
component: HomeComponent
},
{
path: 'dashboardhome',
component: DashboardhomeComponent,
canActivate: [AuthGuard],
children: [
{ path: 'profile', component: ProfileComponent }
]
},
{
path: 'login',
component: LoginComponent
},
];
Upvotes: 2