question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No provider for MdDialogRef

See original GitHub issue

Hi,

I keep having the error 'No provider for MdDialogRef’ even after i followed the tutorial for MdDialog.

I have two components. First component :

import { MdDialog} from "@angular/material";

import { DocumentDialogComponent } from './document-dialog.component';    

@Component({
  selector: 'documents-list',
  template
})
export class DocumentsListComponent {

  constructor(
     public dialog: MdDialog) {
  }

  openFormDialog() {

   let dialogRef  = this.dialog.open(DocumentDialogComponent,
   {
   }
   );
   dialogRef.afterClosed().subscribe(result => {
      this.selectedOption = result;
   });
  }

My second component (The Dialog) :

import { MdDialogRef} from "@angular/material";

@Component({
 selector: 'document-dialog',
 template
})
export class DocumentDialogComponent { constructor( public dialogRef: MdDialogRef ) {}

And my module config :

import { MaterialModule } from "@angular/material";
  import { DocumentsListComponent } from './documents-list.component';
  import { DocumentDialogComponent } from './document-dialog.component';

  imports : [
    MaterialModule.forRoot() 
   ],

  declarations: [
      AppComponent,
      DocumentListComponent,
      DocumentDialogComponent
    ],
    entryComponents: [
      AppComponent,
      DocumentListComponent,
      DocumentDialogComponent
    ],
    providers: [
    ],
    bootstrap: [
      AppComponent
    ]

Why i still have the error : Error in ./DocumentsListComponent class DocumentsListComponent - inline template:0:167 caused by: No provider for MdDialogRef! ?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
kenp77commented, Feb 28, 2017

I found the problem ! When i use html code inside my the component template it Works !!

0reactions
angular-automatic-lock-bot[bot]commented, Sep 5, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"No provider for MdDialogRef!" - Stack Overflow
You may have tried to use your dialog component in a template like this: <pizza-dialog ...></pizza-dialog>. Delete that from your template and open...
Read more >
Testing MdDialog component, getting an error - Google Groups
I am trying to test a component I made and I'm getting this error: Error: No provider for MdDialogRef! Here is my test...
Read more >
providedIn: LazyModule fails with no provider error-angular.js
[Solved]-providedIn: LazyModule fails with no provider error-angular.js ... error when trying to test a component with dialog No provider for MdDialogRef ...
Read more >
Dialog | Angular Material
A dialog is opened by calling the open method with a component to be loaded and an optional config object. The open method...
Read more >
Angular Material Dialog: A Complete Example
Error: No component factory found for CourseDialogComponent. ... NullInjectorError: No provider for MatDialogRef!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found