Reputation: 5622
I have problems creating child routes in main routing module.
{ path: 'vehicles/vehicles', component: VehiclesComponent, data: { permission: 'Pages.Vehicles' }, children: [{ path: 'statistic', component: StatisticVehicleComponent }] },
and I'm trying to redirect to it from code:
this.router.navigate(['/app/main/vehicles/vehicles/statistic']).then(() => {
window.location.reload();
});
but I'm always getting error that route doesn't exist.
What I'm doing wrong, should I register somewhere else the route or I'm calling this router in wrong way?
Upvotes: 1
Views: 343
Reputation: 6643
You can define your routes like this. Move your parent component to empty path of child route.
{ path: 'vehicles/vehicles',
children: [
{ path: '', component: VehiclesComponent, data: { permission: 'Pages.Vehicles' } }
{ path: 'statistic', component: StatisticVehicleComponent }
]
}
Refer Angular Documentation for more info.
Upvotes: 1