I want to implement the user profile page. It would be simple to just use the
/profile/user123 path using:
app-routing.module
{
path: 'profile',
loadChildren: () => import('./modules/profile/profile.module').then(m => m.ProfileModule)
},
profile-routing.module
{
path: ':username',
component: ProfileComponent
},
however, I want to do some fancy URL like /@user123.
Unfortunately, I did not find any clues on how to do it. I tried the following:
app-routing.module
{
path: '@:username',
loadChildren: () => import('./modules/profile/profile.module').then(m => m.ProfileModule)
},
profile-routing.module
{
path: '',
component: ProfileComponent
},
but it didn't work.
There is only one thing that comes to my mind, which is using a Guard checking for the '@' prefix, otherwise redirect to the /not-found page.
Any ideas on how to do the routing using the "Angular" way?