If you are like me and wound up here from google.
My error came when I included an Angular Material Component, rather than it’s module in app.module.ts
special note: whenever you add a new material module to app.module.ts you must stop (and restart) ng serve or you will get this error.
change this
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
BrowserAnimationsModule,
MatDialog, // <====== this is the error
],
to this
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
BrowserAnimationsModule,
MatDialogModule, // <====== this is the solution
],