Components: No provider for MdDialogRef

Created on 27 Feb 2017  Â·  8Comments  Â·  Source: angular/components

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! ?

All 8 comments

provide a plunk please

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

Close the issue then. @kenp77

Sounds like this is not an issue, closing

@kenp77 can you elaborate on what was the issue ? I still cannot seem to resolve this.

Hi can u make a plunkr of the problem?

On May 4, 2017 09:27, "Bhoomi Bhalani" notifications@github.com wrote:

http://stackoverflow.com/questions/43752090/how-to-do-normal-routing-with-
mddialogref-in-angular-4

Thanks in advance.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/material2/issues/3326#issuecomment-299105547,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFyCRlYdUhBPh9EZe9SHuDLs52CwKYZSks5r2W_egaJpZM4MNi8O
.

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

shlomiassaf picture shlomiassaf  Â·  3Comments

MurhafSousli picture MurhafSousli  Â·  3Comments

kara picture kara  Â·  3Comments

3mp3ri0r picture 3mp3ri0r  Â·  3Comments

Hiblton picture Hiblton  Â·  3Comments