0

https://stackblitz.com/edit/angular-gd5gcg?file=app/dialog-overview-example-dialog.html

In this example of the official documentation, I see that the value returned when you close the matdialog is this

 <button mat-button [mat-dialog-close]="data.animal" cdkFocusInitial>Ok</button>

But what happens if you want to send a value calculated in a function previously for example like this

getData(){
this.datos=[1,2,3,4];

}

How can you make that function be called before returning the value to the component that opened the matdialog?

Thanks

kintela
  • 1,283
  • 1
  • 14
  • 32

1 Answers1

0

The solution is quiet simple

 <button mat-button (click)="getData()" [mat-dialog-close]="data.animal" 

Thanks

kintela
  • 1,283
  • 1
  • 14
  • 32