How to get multiple result parameters from closeCallback()


#1

Hello everyone,

I want to get input data from modal view through closeCallback(…args: any[]) => any. Btw, I’m developing with Angular + TypeScript.

This is my code in modal view.

@Component({
  selector: "modal-content",
  template: `
    <StackLayout margin="24" horizontalAlignment="center" verticalAlignment="center">
      <Label text="Enter your password"></Label>
      <TextField hint="Password" [(ngModel)]="password" secure="true"></TextField>
      <StackLayout orientation="horizontal" marginTop="12">
        <Button text="ok" (tap)="close('OK')"></Button>
        <Button text="cancel" (tap)="close('Cancel')"></Button>
      </StackLayout>
    </StackLayout>
  `
})
export class DialogContent {

  private password: string;

  constructor(private params: ModalDialogParams) {
  }

  public close(result: string) {
    console.log(this.password);
    this.params.closeCallback("args1", "args2", "args3", "args4");
  }
}

and I’m calling showModal just like the one below…

...
this.modalService.showModal(DialogContent, options)
      .then((result: any) => {
        console.log(result);
      });
...

But that console.log(result) only prints out “arg1”. How do I get the all the parameters I passed thru closeCallback()?


#2

instead of that, you can do
(param1: any, param2: any, param3: any) and so on for multiple parameters.