I have a question here, I don't know have I follow the best practice of the angular even it is works now:
here is the structure of this nested component: pages
and here is my app-routing.module.ts file:
const routes: Routes = [
{ path: 'register', component: RegisterComponent },
{ path: 'home', component: HomeComponent },
{ path: 'login', component: LoginComponent },
{ path: 'welcome', component: WelcomeComponent, canActivate: [AuthGuard] },
{
path: 'admin',
component: AdminComponent,
canActivate: [AuthGuard],
children: [{ path: 'team', component: TeamComponent }],
},
{ path: '', redirectTo: 'home', pathMatch: 'full' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule {}
So, team component is the sub component of Admin component, there is a navigation bar in Admin component and it will render the team component inside.
Code for Admin component:
<app-nav-admin></app-nav-admin>
<router-outlet></router-outlet>
Code for navigation bar href to team component HTML:
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="admin/team">Team management</a>
</li>
<li class="nav-item">
<a class="nav-link">Link</a>
</li>
</ul>
</div>
and result after click on team link:

as you can see in href value, I assigned ""admin/team"" to go to team component and it really works, but is this is the best practice?
Thanks guys!
