Reputation: 768
When using Materials Dialog, I can't remove the error mentioned in the subject. I had already imported the MatDialogModule and added the entryComponents. I simply want to open my edit-api component when the editAPI button is clicked inside my main component. What am I doing wrong?
Here is the link: https://stackblitz.com/edit/exercise-basic-c
Upvotes: 0
Views: 847
Reputation:
Try following in your edit api component
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
@Component({
selector: 'app-alert-dialog',
templateUrl: './alert-dialog.component.html',
styleUrls: []
})
export class AlertDialogComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<your_component>,
@Inject(MAT_DIALOG_DATA) public data) { }
closeDialog(): void {
this.dialogRef.close();
}
ngOnInit() {
}
}
You need to use @Inject MAT_DIALOG_DATA in your dialog component.
Upvotes: 0
Reputation: 680
you have to change following
import { MatDialog, MatDialogConfig } from '@angular/material';
by
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
to resolve your error.
Upvotes: 1