question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error "NullInjectorError: No provider for X" in version 1.0.15

See original GitHub issue

First of all, thank you this great job on removing the singleton services usage. I upgraded the angular slick version into 1.0.15 this morning (latest). I followed all instructions as described in Migration-from-0.x-to-1.x

No compilation Error, but I get this error when opening the view:

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[MyGridTestComponent -> GridService]: 
  StaticInjectorError(Platform: core)[MyGridTestComponent -> GridService]: 
    NullInjectorError: No provider for GridService!

I followed the instructions to resolve this issue based on stack trace messages, so I found that I have to provide the service “GridService” inside my component (no singleton service). Other services are also provided (each time the error message changes, I add the necessary providing).

Finally, to got it working, I was obliged to provide all this list of services internally to my component:

 providers :[ AngularSlickgridComponent, GridService, ControlAndPluginService, ExportService, 
               FilterService, SortService, GridStateService, ResizerService, 
               FilterFactory, SlickgridConfig]

NB: Services FilterFactory and SlickgridConfig are not exported by default (ie version from npm). So, I built the library and made them public. I installed the locally modified library.

NB: I tried the provide only “SlickPaginationComponent” as it become a service, but it fails with the same message error.

NB: Maybe one other possibility (that I haven’t tested): MyGridTestComponent will extend AngularSlickgridComponent , I think I will not be in a need to rebuild the library, but I’ll have provide about 10 services to pass them as arguments to the super class ‘AngularSlickgridComponent’

My question: Am I doing wrong from the beginning ? Do we really need for this number of services to be injected (provided) ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sabeurchcommented, Jun 19, 2018

It works perfectly. You can close this ticket. Gracias.

0reactions
sabeurchcommented, Jun 19, 2018

Many thanks Ghislain ! I’ll install and give it a try, then confirm the closure of this ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: No provider for t - angular - Stack Overflow
You are trying to use a service that is not listed in providers of your AppModule. Add the service to a providers list...
Read more >
[Debugging] NullInjectorError: No provider for {Class}!
In this video, you'll learn what the error " NullInjectorError : No provider for {Class}!" means, how to debug it, and prevent it...
Read more >
NG0201: No provider for {token} found! - Angular
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping...
Read more >
How to fix angular error main.js:1 NullInjectorError
js:1 NullInjectorError: No provider for i! This error occurs in Angular when you create a singleton service and implement ...
Read more >
@uirouter/angular-hybrid: Versions | Openbase
Full version history for @uirouter/angular-hybrid including change logs. ... upgrade: Fix "no provider" error while injecting a falsy ng1 provider (1a06a9a).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found