Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve all parameters for MatDialogRef angular 4

Tags:

I'm working on Angular 4 and I'm trying to setup material package, and here I'm trying to try dialog, but it doesn't work maybe because of material package I'm not sure.

This is my (dialog.components.ts):

import {Component, OnInit} from '@angular/core';
import {MatDialogRef} from '@angular/material'

@Component({
    selector: 'app-dialog',
    templateUrl: './dialog.component.html',
    styleUrls: ['./dialog.component.css']
})
export class DialogComponent implements OnInit {

    public receivedNode: any;

    constructor(public dialogRef: MatDialogRef<DialogComponent>) {
    }

    ngOnInit() {
    }

}

And in my module:

import {MatButtonModule,MatMenuModule,MatToolbarModule,MatIconModule,MatCardModule, MatDialogRef} from '@angular/material';


 @NgModule({
        imports: [
            CommonModule,
            MatButtonModule,
            MatMenuModule,
            MatToolbarModule,
            MatIconModule,
            MatCardModule,
            RouterModule.forRoot(
                appRoutes,
                {enableTracing: true}
            ),
        ],
        declarations: [],
        exports: [
            MatButtonModule,
            MatMenuModule,
            MatToolbarModule,
            MatIconModule,
            MatCardModule
        ],
        entryComponents: [DialogComponent],
        providers: [MatDialogRef]
    })
    export class DialogModule {
    }

I got this error: Uncaught Error: Can't resolve all parameters for MatDialogRef: (?, ?, ?).

Any ideas?

EDIT

My call function:

openPopup(){
        const config = new MatDialogConfig();
        const dialogRef: MatDialogRef<DialogComponent> = this.dialog.open(DialogComponent, config);

        dialogRef.componentInstance.receivedNode = "test";
        console.log("test");
    }