Components: StaticInjectorError(AppModule)[MatDialogTitle -> MatDialogRef]

Created on 22 Oct 2018  路  7Comments  路  Source: angular/components

Bug, 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.

needs clarification

Most helpful comment

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.

All 7 comments

Can you share a reproduction?

Can you share a reproduction?

Well, not really sorry, as I dont know what's causing it. The error message is pretty clear about "No provider for MatDialogRef! " and I thought I new what that meant and how to fix it, but that is not the case here. As I said, all I did was upgrade. I guess I could try a downgrade.. sigh but unless I know the cause that wont help me fix it.

Im more confused about "StaticInjectorError(AppModule)[MatDialogTitle -> MatDialogRef]" . What does that mean? Does it mean it's failing to inject MatDialogTitle into MatDialogRef? Im not sure how I could do anything that would cause that to fail.

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.

Without a reproduction it's impossible for us to determine if this is a valid issue in the component itself. We recommend using something like StackOverflow or gitter for getting help debugging your application.

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 had the same issue...
turn out that i was using the same component (by mistake) in a template (display it directly as '' without opening with 'dialog.open').

hope this stupid o f mine mistake will help someone...

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LoganDupont picture LoganDupont  路  3Comments

constantinlucian picture constantinlucian  路  3Comments

vitaly-t picture vitaly-t  路  3Comments

dzrust picture dzrust  路  3Comments

RoxKilly picture RoxKilly  路  3Comments