将函数参数传递给ngSweetAlert

时间:2017-06-01 16:11:33

标签: javascript angularjs sweetalert

帮我找到解决方法:

我正在使用针对sweeAlert的ngSweeAlert angulajs指令。所以,我有一个简单的代码:

function test() {
  swal({
    title: "Are you sure?",
    text: "You will not be able to recover this imaginary file!",
    type: "warning",
    showCancelButton: true,
    confirmButtonText: "Yes, delete it!",
  },
  function(isConfirm){
    if(isConfirm) alert("foobar")
    else alert("notfoobar")
  }); 
} 

我想传递测试功能的函数:

function myFunction( isConfirm ) {
     if(isConfirm) alert("foobar")
     else alert("notfoobar")
}

测试功能以这种方式工作:

function test(callBack ) {
      swal({
        title: "Are you sure?",
        text: "You will not be able to recover this imaginary file!",
        type: "warning",
        showCancelButton: true,
        confirmButtonText: "Yes, delete it!",
      },
      callback
      ); 
    } 

我的问题是myFunction功能是:

 function myFunction( isConfirm, param1, param2 ) {
         if(isConfirm) alert("foobar"+param1);
         else alert("notfoobar"+param2);
    }

然后,第一个参数仅在按下确定或取消按钮时发生。我叫测试功能

test( function(){ return myFunction(undefined,'beautiful','uggly') } )

我的问题是:当我在isConfirm之后用另外两个参数param1和param2挥动一个函数时,如何为sweetAlert进行isConfirm'true'或'false'以进行用户交互

1 个答案:

答案 0 :(得分:0)

 SumBuilder s1 = AggregationBuilders.sum(field2Sum).field(field2);
 SumBuilder s2 = AggregationBuilders.sum(field1Sum).field(field1);