StaticInjectorError – NullInjectorError: No provider for {ServiceClass}

Angular throws a StaticInjectorError, when you try to do dependency injection as below:

To fix this you can add the metadata “Provider” inside the component decorator.


Or you can always go to the relevant module and register all the components dependencies in the provider meta tag there. This will be more memory efficient as angular will instantiate only single instance of that service in the memory.

Hope this helps ! Happy coding.

Over 6 years of experience in Software Development and Front End Development. Experience in Coding, Testing, Design on Microsoft Platform Technologies, HTML/CSS, scripting etc. Area of exposure includes software development using Microsoft Asp NET, C# and SQL Server for web.

Leave a Reply