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 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #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

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
Should we ever delete data from a database?MiscellaneousHow different is Handling Events in React vs HTML DOM?ReactCommon Table Expressions (CTE) in PostgreSQLPostgresHow to add Google Map in WordPress using ACF?WordPress6 Different Functions to Sort Arrays in PHPPHPWordPress: How to loop through ACF group fields?WordPressHow to create a cross-browser smooth scrolling with jQuery?jQueryThe basics of CSS Box modelCSSHow to change the Login Logo in WordPress?WordPressLIMIT and OFFSET in PostgresPostgresHow to modify the latest post array using get_posts() in WordPress?WordPressKilling A Project Part 3: How can an organization ensure that a doomed project is killed as early as possible?Miscellaneous