-2

Actually I have a component typescript file having two classes one for normal component and another one for mat-dialog,

I got the data from http, but I want to pass to parent component.

I want to send the results of this.api.filterHotels(this.filterForm.value); to parent component , How? since Iam not using <Mob-filter-dialog> tag anywhere in html file.

  • 1
    Possible duplicate of [Pass data from child to parent component Angular2](https://stackoverflow.com/questions/42107167/pass-data-from-child-to-parent-component-angular2) – CTheCheese Jan 05 '19 at 14:07

1 Answers1

0

Mat Dialog has a specific usage and do not work with HTML tags. Use the provided injector. You can pass data through the dialog.close() method that takes one argument. Then use the afterClosed observable to fetch that data.

Here is a piece of the mat-dialog official doc:

dialogRef.afterClosed().subscribe(result => {
  console.log(`Dialog result: ${result}`); // Pizza!
});

dialogRef.close('Pizza!');

Good luck, it's not an easy one to get at first, but the documentation explains it well

Alex
  • 1,090
  • 7
  • 21