Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
Cannot find provider for ActivatedRoute in library

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
  ) { }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!