I wish to have access to RouterModule directive(routerLink) in my child Module, tough I don't have any Routes to add to the forChild method. Which way should I import RouterModule in my @NgModule class without getting another instance of Router(That was already instantiated in the root application module through RouterModule.forRoot(ROUTES)):
@NgModule({
imports: [RouterModule.forChild([])]
})
OR
@NgModule({
imports: [RouterModule]
})
Both seem to work in my app. I'm just not sure if the service instance is happening twice.
I've read these two entries of the documentation:
The result is that the root application module imports RouterModule.forRoot(...) and gets a Router, whereas all route components import RouterModule which does not include the Router.[1]
And:
For submodules and lazy loaded submodules the module should be used as follows[2]:
@NgModule({
imports: [RouterModule.forChild(ROUTES)]
})
class MyNgModule {}