I'm using Angular 10. In the CoreModule
class I have the component NavbarComponent
. I have this HTML template in the NavbarComponent
component:
<mat-tab-group mat-align-tabs="end">
<mat-tab routerLinkActive>Home</mat-tab>
<mat-tab routerLink="/user/registration"></mat-tab>
<mat-tab>Login</mat-tab>
</mat-tab-group>
After clicking on the link, nothing happens. URL does not change. It's the same all the time http://localhost:4200/home
.
In the class of the HomeModule
module there is a component with an HTML template:
<app-navbar></app-navbar>
<app-footer></app-footer>
The HomeRoutingModule
class contains arrays:
const routes: Routes = [{ path: '', component: HomeComponent }];
The AppRoutingModule
class contains arrays:
const routes: Routes = [
{
path: 'home',
loadChildren: () => import('./modules/home/home.module').then(m => m.HomeModule)
},
{ path: 'user',
loadChildren: () => import('./modules/users/users.module').then(m => m.UsersModule)
},
{
path: '',
pathMatch: 'full',
redirectTo: 'home'
},
];
The UsersRoutingModule
class contains arrays:
const routes: Routes = [
{
path: 'user',
component: UsersComponent,
children: [
{
path: 'registration',
data: { title: 'registration' },
component: UserRegistrationComponent,
}
]
}
];
project structure:
I do not know how to make the redirection to the UserRegistrationComponent
carried out. When I click:
<mat-tab routerLink ="/user/registration ">
URL does not change.
Please help. Thank you very much.