Yogesh Chauhan's Blog

Solution to “NullInjectorError: No provider for module” in Angular 9

in Angular on May 16, 2020

The error occurs because of missing providers in app.module.ts

The error mostly occurs when we try to change one of the services and class and forget to update the providers in the app.module

Just add the missing providers and the error will go away.

Look at this code:


@NgModule({
  imports: [
    BrowserModule,
    ...OtherModules...
  ],

  providers: [blah..blah...blah],   //<-- add your missing providers here

  bootstrap: [ AppComponent ]
})
export class AppModule {}

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
How to select an element using its ID without the high specificity of the ID selector?CSSHow to Access a Global Variable From Inside a Function in PHP?PHPContent Blocks in SCSS (Sass)SCSSTackle Accessibility in React with JSXReactWhat is ECMAScript?JavaScriptHow to detect the Blog Page in WordPress?WordPressWhat is the difference between float and double?Miscellaneousfor @each loop in SCSSSCSSHow to Secure Web or Mobile Browsers?MiscellaneousHow to create a vertically rotating texts using CSS?CSSHow to scroll contents of HTML body horizontally and vertically using JavaScript?JavaScriptSafe Practice to add Links to cross-origin destinationUI/UX