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
  • 29,816
  • 26
  • 86
  • 96
user1015388
  • 1,143
  • 3
  • 14
  • 33

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
  • 740
  • 5
  • 13
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
  • 680
  • 1
  • 7
  • 19