StaticInjectorError(AppModule)[MatDialogTitle -> MatDialogRef]
See original GitHub issueBug, feature request, or proposal:
Bug?? Either that or Ive done something wrong
What is the expected behavior?
No error when loading
What is the current behavior?
On app startup Im seeing:
StaticInjectorError(AppModule)[MatDialogTitle -> MatDialogRef]
Full error is:
core.js:12301 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[MatDialogTitle -> MatDialogRef]: StaticInjectorError(Platform: core)[MatDialogTitle -> MatDialogRef]: NullInjectorError: No provider for MatDialogRef! Error: StaticInjectorError(AppModule)[MatDialogTitle -> MatDialogRef]: StaticInjectorError(Platform: core)[MatDialogTitle -> MatDialogRef]: NullInjectorError: No provider for MatDialogRef! at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:691) at resolveToken (core.js:928) at tryResolveToken (core.js:872) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:769) at resolveToken (core.js:928) at tryResolveToken (core.js:872) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:769) at resolveNgModuleDep (core.js:17435) at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:18124) at resolveDep (core.js:18495) at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:691) at resolveToken (core.js:928) at tryResolveToken (core.js:872) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:769) at resolveToken (core.js:928) at tryResolveToken (core.js:872) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:769) at resolveNgModuleDep (core.js:17435) at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:18124) at resolveDep (core.js:18495) at resolvePromise (zone.js:814) at resolvePromise (zone.js:771) at zone.js:873 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:13842) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595) at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:500) at invokeTask (zone.js:1540)
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular Material: 6.4.7 and 7.0 Angular 7.0.2 Windows 10 Typescript 3.0.3 Chrome
Is there anything else we should know?
Everything was fine until I updated to Angular 6.4.7 (and whatever version of Material went with that). Tried v 7 and no difference.
Ive checked that Im refering to MatDialogModule everywhere but I dont fully understand what the issue is since the error message ios somewhat cryptic.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
I was really just looking for an explanation of the problem, not a solution. Stackoverflow is next to useless for complex issues like this. The people here are usually the most informed and knowledgeable, and therefore the most overworked I guess.
I tried the solutions offered here: https://stackoverflow.com/questions/52885991/staticinjectorerrorappmodulematdialogtitle-matdialogref/52975331#52975331 and here: https://github.com/angular/material2/issues/8419.
i.e., I added this to my MaterialModule:
providers: [ { provide: MatDialogTitle, useValue: {} }, { provide: MatDialogRef, useValue: {} }, { provide: MAT_DIALOG_DATA, useValue: [] } ]
This removes the error message from the console, but now my application started up and show the content of a dialog as the home page.