I've created UserComponent which route is:
app-routing.module.ts
{
path: ':username',
component: UserComponent,
children: [
{ path: 'work-time', component: WorktimeComponent },
{ path: 'absence', component: AbsenceComponent },
],
}
username is value of an input from LoginComponent.
The problem is when go to child component path for example "localhost:4200/:username/work-time" and want to move back to "localhost:4200/:username" using routerLink it just shows the main page which is separated component called HomeComponent.
What I've tried to do with routerLink is:
user.component.html
<a routerLink=":username">
<h1>test</h1>
</a>
What I want is to create a routerLink which will route to for example "localhost:4200/peter" but I really don't know how to do it.
<a routerLink="/:username">? - reflexdemon<a routerLink="./"></a>. Is it a bad practice or can I just leave it like that? - illumiMatii<a [routerLink]="username"></a>. It is not a bad practice. Just code looks good. - reflexdemon