I may struggle to articulate the problem, but I do have a StackBlitz to help.
https://stackblitz.com/edit/angular-brhyir
Notice the Lazyloading 'users'...
app.routes.ts
//import { NgModule } from '@angular/core';
import { Routes } from '@angular/router';
import { SecureComponent } from './layouts/secure.component';
import { HelloComponent } from './hello.component';
//SECURE
export const SECURE_ROUTES: Routes = [
{ path: '',
component: HelloComponent,
data: {
}
},
//Lazyloading
{ path: 'users',
data: {
breadcrumb: 'Users',
},
loadChildren: './users/user.module#UserModule' }
];
export const routes: Routes = [
{ path: '', component: SecureComponent, data: { title: 'Secure Views' },
children: SECURE_ROUTES },
];
this works, but...
user.routes. ts
import { Routes } from '@angular/router';
import { UsersComponent } from './users.component';
import { UserComponent } from './user/user.component';
import { UserTwoComponent } from './user/user-two.component';
export const UserRoutes: Routes = [
{ path: '',
component: UsersComponent,
children: [
{
path: 'user',
component: UserComponent,
data: {
breadcrumb: 'New'
},
children: [
{
path: 'user2',
component: UserTwoComponent,
data: {
breadcrumb: 'New2'
}
}
]
}
]
}
];
So if you click the buttons you will witness the problem. Which is, the route is correct (users/user) BUT it does NOT load the 'UserComponent', instead it still shows the 'UsersComponent'. Why I do not know?