Reputation: 688
I try to set a Child Route as default route that loads when i just enter the site address.
const routes: Routes = [
{path: '', pathMatch: 'full', redirectTo: ''},
{
path: '', component: FrameDefaultComponent,
children: [
{path: '', component: SiteCalculatorComponent}
]
},
];
But this dont work... When i give the SiteCalculatorComponent
any route like calc and redirect from level 1 to 'calc'
then it works. I know... But the point is that i want to load it "without" any path ;)
Is this possible? If yes how?
Upvotes: 1
Views: 1402
Reputation: 95
I have one router like this:
const firstRoutes: Routes = [
{
path: '',
children: [
{
path: 'parent-url',
children: secondRoutes
}
]
}
];
And second one like this:
export const secondRoutes: Routes = [
{
path: '',
children: [
{
path: '',
redirectTo: 'child-route',
pathMatch: 'full'
},
{
path: 'child-route',
component: ChildComponent
}
]
}
];
My ChildComponent can be called with /child-route or /parent-url/child-route. I want to disable calling my function with both routs, so to set able to call it only with /parent-url/child-route.
I dont know how to check if there is /parent-url and if it is not there to disable calling ChildComponent without that /parent-url . in whole url?
Upvotes: 2
Reputation: 688
The solution:
{
path: '', component: FrameDefaultComponent,
children: [
{path: '', component: SiteCalculatorComponent}
]
},
Upvotes: 1