I'm quite new with Angular routing and couldn't find any solution for this case. I've got a Login component and a User module. There's one <router-outlet> in App component, one in UserBase component in User module. Here's my routing declaration.
app.module.ts
const routes: Routes = [
{
path: 'login',
component: LoginComponent
},
];
imports: [
RouterModule.forRoot(routes),
UserModule,
],
user.module.ts
const routes: Routes = [
{
path: ':username',
component: UserBaseComponent,
children: [
{
path: '',
component: UserDetailsComponent,
},
{
path: 'progress',
component: ProgressComponent,
},
{
path: 'timeline',
component: TimelineComponent,
},
{
path: 'leaderboard',
component: LeaderboardComponent,
}
],
}
];
imports: [
RouterModule.forChild(routes)
]
It works fine with the path for user module, but it keeps recognizing 'login' as an username and not navigate to Login component. Actually, if I add a static path before the param like this, it works correctly.
{
path: 'user',
children: [
{
path: ':username',
component: UserBaseComponent,
children: [
{
path: '',
component: UserDetailsComponent,
},
{
path: 'progress',
component: ProgressComponent,
},
{
path: 'timeline',
component: TimelineComponent,
},
{
path: 'leaderboard',
component: LeaderboardComponent,
}
],
}
]
}
Could anyone explain why?