How to get data sent to a MatDialog that is a ng-template?
Template
<button mat-button (click)="openDialog()">Open</button>
<ng-template #dialogRef>
    {{data?}} <!-- <<< Here is the problem data is undefined -->
</ng-template>
Component
export class SomeComponent {
    @ViewChild("dialogRef") dialogRef: TemplateRef<any>;
    constructor(private dialog: MatDialog) { }
    openDialog(): void {
        this.dialog.open(this.dialogRef, { data: "some data" });
    }
}
                It should be available through template variable:
<ng-template #dialogRef let-data>
                        ^^^^^^^^
   {{data}}
</ng-template>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With