通过带有参数的javascript函数作为变量

时间:2019-03-04 10:55:17

标签: javascript angular typescript

在这里,我正在从CustomModalComponent调用delete函数。但是我想将参数传递给删除功能。

我想将数据传递到引用该函数的confirmAction: this.delete变量

有没有可能?

  delete = (data) => {
    this.systemAdminSvc.deleteSystemAdmin(data.id).subscribe((res: IHttpResponse) => {
      this.handleApiResponse(res);
    });
  }

  openDelete = (data) => {
    const modalInput: ICustomModalData = {
      header: 'CONFIRMATION',
      modalBody: 'Are you sure you want to delete the item ?',
      confirmAction: this.delete,
      okText: 'Confirm',
      cancelText: 'Cancel'
    };

    this.dialog.open(CustomModalComponent, {
      width: '400px',
      data: modalInput
    });
  }

0 个答案:

没有答案