So I have a module structure like this:
app
----pages
---------dashboard
---------posts
Both dashboard
and posts
have their own routing.
Here is how the routing looks like:
Pages
const routes: Routes = [
{
path: '',
component: Pages,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', loadChildren: './dashboard#DashboardModule' }
{ path: 'posts', loadChildren: './posts#PostsModule' }
]
}
];
export const routing = RouterModule.forChild(routes);
Dashboard
const routes: Routes = [
{
path: '',
component: DashboardComponent
}
];
export const routing = RouterModule.forChild(routes);
Posts
const routes: Routes = [
{
path: '',
component: PostsComponent
},
...
];
const routing = RouterModule.forChild(routes);
Everything works fine but when I try to import the PostsModule
in the DashboardModule
like this:
import { PostsModule } from '../posts';
@NgModule({
imports: [
routing, // Dashboard routes
CommonModule,
...
PostsModule
]
})
export class DashboardModule { }
and load http://localhost:3000/#/dashboard
, it shows the PostsComponent
, instead of DashboardComponent
just because I imported the "sibling" module
How can I fix this?