how sent data to dilaog angular material

Solutions on MaxInterview for how sent data to dilaog angular material by the best coders in the world

showing results for - "how sent data to dilaog angular material"
Theon
13 Oct 2020
1// app.component.ts
2import { Component } from '@angular/core';
3import { MatDialog } from '@angular/material/dialog';
4import { MyDialogModalComponent } from './modals/my-dialog-modal/my-dialog-modal.component';
5
6@Component({
7  selector: 'app-root',
8  templateUrl: './app.component.html',
9  styleUrls: ['./app.component.css']
10})
11export class AppComponent {
12  title = 'angular-material-tree-tutorial';
13
14  dialogValue: string;
15  sendValue: string;
16
17  constructor(
18    public dialog: MatDialog
19  ) { }
20
21
22  openDialog(): void {
23    const dialogRef = this.dialog.open(MyDialogModalComponent, {
24      width: '250px',
25      backdropClass: 'custom-dialog-backdrop-class',
26      panelClass: 'custom-dialog-panel-class',
27      data: { pageValue: this.sendValue }
28    });
29
30    dialogRef.afterClosed().subscribe(result => {
31      console.log('The dialog was closed', result);
32      this.dialogValue = result.data;
33    });
34  }
35
36}
37