Answers for "inject data in mat dialog"

0

inject data in mat dialog

export interface DialogData {
  animal: 'panda' | 'unicorn' | 'lion';
}
...
export class DialogDataExample {
  constructor(public dialog: MatDialog) {}

  openDialog() {
    this.dialog.open(DialogDataExampleDialog, {
      data: {
        animal: 'panda'
      }
    });
  }
}

@Component({
  selector: 'dialog-data-example-dialog',
  templateUrl: 'dialog-data-example-dialog.html',
})
export class DialogDataExampleDialog {
  constructor(@Inject(MAT_DIALOG_DATA) public data: DialogData) {}
}
Posted by: Guest on September-22-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language