Error "NullInjectorError: No provider for X" in version 1.0.15
See original GitHub issueFirst 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:
- Created 5 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
It works perfectly. You can close this ticket. Gracias.
Many thanks Ghislain ! I’ll install and give it a try, then confirm the closure of this ticket.