1
所以我有一個模塊結構是這樣的:角2導入其他「兄弟姐妹」模塊注入了錯誤的組件
app
----pages
---------dashboard
---------posts
兩個dashboard
和posts
有自己的路由。
下面是路由的樣子:
頁面
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);
儀表板
const routes: Routes = [
{
path: '',
component: DashboardComponent
}
];
export const routing = RouterModule.forChild(routes);
帖子
const routes: Routes = [
{
path: '',
component: PostsComponent
},
...
];
const routing = RouterModule.forChild(routes);
一切工作正常,但是當我嘗試在DashboardModule
這樣導入PostsModule
:
import { PostsModule } from '../posts';
@NgModule({
imports: [
routing, // Dashboard routes
CommonModule,
...
PostsModule
]
})
export class DashboardModule { }
和負載http://localhost:3000/#/dashboard
,它顯示了PostsComponent
,而不是DashboardComponent
只是因爲我輸入了「兄弟「模塊
我該如何解決這個問題?