2017-05-02 69 views
0

我在我的項目中使用Angular2,我有幾個模塊。角模塊之間的全局路由

我有被稱爲BaseModule 並且具有例如兩個(或更多)鹼基模塊額外的模塊 - FirstModuleSecondModule

每個模塊都有自己的路由。 BaseModule有系統的基本路線, FirstModuleSecondModule有他自己分開的路線。

我要像

/user/10/profile

ProfileComponent用戶包含到FirstModule

創建路線的另一個例子

/user/10/stories

StoriesComponent用戶包含到FirstModule

/user/10/news

NewsComponent用戶包含到SecondModule !!!!

但角路由器允許像只路線:

/firstmodule/......

/secondmodule/......

所以,他們應該按模塊進行分組。

我想用模塊來做這件事,因爲我想讓我的應用程序有異步(懶惰)加載的部分。

據我所知,當我們異步(懶惰)加載組件時,Angular不允許變體。

任何人有想法如何創建我想要的?

回答

0

對於根模塊中的路由,將您的根定義爲RouterModule.forRoot(['']),其他模塊中的路由使用RouterModule.forChild([''])。由於您的孩子模塊將在父母的imports這將正確路由。