mohanarangan
mohanarangan

Reputation: 109

Error occurring in Angular Material Dialog Popup

I have been trying to put Modal popup in my site using Angular Material Dialog, 1st time it all came perfect But it started to show error after..

I have imported the MatDialogModule in moduleTs import { MatDialogModule } from '@angular/material/dialog'; also declared in imports

In ComponentTs:

constructor(public dialog: MatDialogModule) {};
  ngOnInit() {
  }
  openDialog(){
    this.dialog.open(DialogStudyModeComponent);
  }

the error shown was : Property 'open' does not exist on type 'MatDialogModule'.

45 this.dialog.open(DialogStudyModeComponent);

Upvotes: 0

Views: 1539

Answers (1)

Priscila Anjos
Priscila Anjos

Reputation: 106

you importing the wrong dialog.

MatDialogModule is to be put in your module.

MatDialog is for your component.

So:

  import {MatDialog} from '@angular/material/dialog';

  constructor(public dialog: MatDialog) {}
  openDialog() {
      this.dialog.open(DialogStudyModeComponent);
  }

Upvotes: 1

Related Questions