在Angular4中,您可以在pathToMyModule#MyModule
的路由配置中使用loadChrildren
屬性來延遲加載模塊。我想知道是否有任何屬性,我可以指定總是加載我的模塊(所以基本上禁用延遲加載)。Angular4如何以熱切的方式加載模塊
0
A
回答
1
導入啓動應用程序時引導的模塊中的所有模塊。通常它被稱爲AppModule
。這是默認的方式。那麼請不要使用loadChrildren
。這些模塊應該分層次導入,然後所有的模塊將被熱切導入。
@NgModule({
imports: [
AppRoutingModule,
LoginModule,
//here you should import all other modules, or other the modules should import each other hierarchically
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})
export class AppModule {
}
@NgModule({
imports: [
RouterModule.forRoot([
{path: '', component: SomeComponent}
],
exports: [
RouterModule
]
})
export class AppRoutingModule {
}
@NgModule({
imports: [
LoginRoutingModule
]
})
export class LoginModule {
}
@NgModule({
imports: [
RouterModule.forChild([
{
path: 'login',
children: [
{path: '', pathMatch: 'full', redirectTo: 'somepath'},
{path: 'somepath', component: SomeOtherComponent},
]
}
])
],
exports: [
RouterModule
]
})
export class LoginRoutingModule {
}
相關問題
- 1. 如何獲得mongoid的熱切加載?
- 2. Angular4。如何爲懶惰加載的子模塊聲明組件/導入模塊?
- 3. Laravel模特熱切加載和訂購
- 4. 我如何訂購在軌的熱切加載的模型
- 5. 如何讓requirejs以多態方式加載模塊?
- 6. EF4.1熱切加載查詢
- 7. 共享Angular4模塊
- 8. 如何隨時加入一個模型以加載熱心
- 9. 如何在RequireJS中結合不同的模塊加載方式?
- 10. 如何以模塊化的方式在路由後面加載Angular代碼?
- 11. 如何以編程方式加載在python包含在包內的模塊3.2
- 12. 優化Rails中的熱切加載
- 13. 熱切加載所有實體的DbContext
- 14. 以模塊化的方式
- 15. 如何以編程方式禁用和卸載Drupal模塊?
- 16. 如何加載角模塊
- 17. 如何加載mongojs模塊
- 18. 模擬非關聯表的熱切加載
- 19. Rails禁用特定模型的熱切加載
- 20. 如何下載Angular4
- 21. 如何以Angular4的字符串形式下載網站?
- 22. NHibernate - 嵌套熱切加載被忽略
- 23. 加載父項時熱切取孩子
- 24. Hibernate - FetchType.LAZY熱切加載數據
- 25. Angular4材料:如何加載內容sidenav
- 26. 如何以編程方式加載UIViewController?
- 27. 如何以編程方式加載UIViewController
- 28. 如何以RESTful方式「延遲加載」?
- 29. 如何使用Rails和Ancestry在模型後代上執行熱切加載
- 30. 帶有自定義加載器的熱模塊替換中斷
讀這篇文章[避免常見的混亂與角模塊(https://blog.angularindepth.com/avoiding-common-confusions-with-modules-in-angular-ada070e6891f) –