Reputation: 41
I'm trying to define a unique URL structure, however I cannot seem to get the children / not-found routes to work as I'm expecting.
eg:
www.mysite.com/:id/home www.mysite.com/:id/about-us
I've constructed a routing module, and I'm doing something like this:
const routes: Routes = [
{
path: '',
component: ConciergeComponent,
pathMatch: 'full'
},
{
component: ConciergeComponent,
path: ':id',
children: [{
path: 'home',
component: HomeComponent
}]
},
{
path: '**',
component: NotFoundComponent
}
];
If I navigate to www.mysite.com, the concierge is called as expected. I'm doing some pre-flight checks based on business rules, before redirecting the user to the correct 'landing page'.
However, when I navigate to /usr-12/home it does not work, instead it gives me the NotFound (which is expecting when a route does not exist). I feel that I'm missing something very small here?
Upvotes: 1
Views: 231
Reputation: 336
Try this.
const routes: Routes = [
{
path: '',
component: ConciergeComponent,
pathMatch: 'full'
},
{
component: ConciergeComponent,
path: ':id/home',
children: [{
path: 'home',
component: HomeComponent
}]
}
];
Upvotes: 1