I'm trying to configure my application to make use of Lazy Loaded Modules in RC5. This is the problem i'm running in to.
I have a module that uses RouterModule.forChild(router) and gets lazy loaded lets call it LevelOneModule. This module also has a few modules that get lazy loaded lets call them LevelTwoModule-s. This works for the most part but i have to mayor problems:
- I provide a service in my LevelOneModule that i need to have as a singleton in LevelTwoModule-s but for some reason each LevelTwoModule has its own instance of the service.
Here is an example of the code:
LevelOneModule
@NgModule({
imports: [
SharedModule,
levelOneRouter
],
providers: [SomeService],
declarations: [...]
})
LevelTwoModule:
@NgModule({
imports: [
SharedModule,
levelTwoRouter
],
providers: [],
declarations: [...]
})
- I want the LevelOneModule to register some declarations which i need available in multiple LevelTwoModule-s and i'm not quit sure how to achieve this.
If i just try to register the declarations in the LevelOneModule:
declarations: [SomeComponent, ANotherComponent]
I get the unrecognized element error, and if i try to register the declaration in each LevelTwoModule separately i get the is part of the declarations of 2 modules error.
I've also tried to make another SharedModule just for the LevelOneModule and that didn't work also.
Any help or info is greatly appreciated, just something to point me in the right direction.