1

I have an angular dialogservice which opens up a popup, the popup has one field whose text has to be captured once you click 'yes', how can I pass value back to parent from dialogservice

  this.popupservice.addDialog(Component,
                 {
                     title: 'Confirmation',
                     message: 'test'

                 })
                 .subscribe((isConfirmed) => {
                     if (isConfirmed) {
                     // catch returnText here
                         return true;
                     } else {
                         return false;
                     }
                 });

export interface CompModel {
  title: string;
  message: string;
  returnText: string;
}                
export class Component extends
  PopupComponent<CompModel, boolean>{
  implements CompModel {
  title: string;
  message: string;
  returnText: string

    confirm() {
    // send return from here
    this.close();
  }
  }
Machavity
  • 30,841
  • 27
  • 92
  • 100
user1015388
  • 1,283
  • 4
  • 25
  • 45

2 Answers2

0

Simply, you can use EventEmitter in the service layer and receive any events from the service.

Please refer this link : Delegation: EventEmitter or Observable in Angular

Jihoon Kwon
  • 745
  • 5
  • 14
0

You can pass the value as an argument in the close() method and you can access this value in your subscription. Check the docs for this.

Arjun Panicker
  • 730
  • 1
  • 8
  • 20