在bootbox回调函数中调用另一个函数

时间:2018-09-06 06:40:42

标签: javascript angular bootbox

您好,我有一个需要在引导框提示符的回调中调用的函数。

//启动箱功能

  refundfn = () => {
      let refund;       
      bootbox.prompt({
          title: "Partial Amount",
          inputType: 'number',
          buttons: {
              cancel: {
                  label: 'Full Refund'
              },
              confirm: {
                  label: 'Partial Refund'
              }
          },
          callback: function (result) {
              if (result == null) {
                  refund = document.getElementById("trRefundAmnt").innerHTML; 
                  this.refundAPICall(refund);
              } else {
                  refund = result; 
                  this.refundAPICall(refund);
              }
          }
      });  
  }

//需要被称为函数

  refundAPICall = (refundAmnt) => {
      this.spinner = true;
      let orderId = document.getElementById("trOrderId").innerHTML;
      let systemId = document.getElementById("trSysId").innerHTML;
      let response = this.apiService.getRefund(systemId, orderId, refundAmnt).subscribe(
          success => {
              this.spinner = false;
              this.toastr.success("Success");
          }, error => {
              this.spinner = false;
              if (error.error.errorCode == 403) {
                  this.toastr.error(error.error.errorMessage);
              } else {
                  this.toastr.error(error.error.errors[0].userMessage);
              }
          }
      );
  }

但是我做不到。收到错误TypeError:this.refundAPICall不是函数

0 个答案:

没有答案