0
votes

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);

1

1 Answers

1
votes

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);
  }