I am creating a library with a module that I would like to use the router to get the queryParams from using the ActivatedRoute service. However, when the page loads I get a DI error:
NullInjectorError: No provider for ActivatedRoute!
I am using storybook which sets up the app module like this:
export default {
decorators: [
moduleMetadata({
imports: [
MyModule,
RouterModule
]
})
]
}
Next in the library the module looks like this:
@NgModule({
declarations: [
MyComponent
],
imports: [
RouterModule // Tried with and without this line
]
})
export class MyModule {}
Then finally I create the component like this:
@Component({})
export class MyComponent {
constructor(
// Cannot find this service
private readonly activatedRoute: ActivatedRoute
) { }
}