I've got a published library containing a component that uses [routerLink] in it's template. After installing the library in my application, I get the error NullInjectorError: R3InjectorError(AppModule)[Router -> Router -> Router]: NullInjectorError: No provider for Router!
Within the module in the library the RouterModule is imported and looks like this:
@NgModule({
declarations: [
Component
],
exports: [
Component
],
imports: [
CommonModule,
RouterModule,
TranslateModule
]
})
export class LibWithComponentModule {
}
Within my application, the RouterModule is configured as follows:
const routes: Routes = [{
path: '',
component: RootComponent
}];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
The app.module.ts
looks like this:
declarations: [
AppComponent,
RootComponent
],
imports: [
BrowserModule,
AppRoutingModule,
LibWithComponentModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
But I thought the RouterModule is going to be provided? What am I doing wrong?