大家好我的角度控制器上的每个人我都有以下方法:
$scope.scanSuccess = function(result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
};
$scope.scanSuccessW = function(){
return $scope.scanSuccess;
}
有没有办法从scanSuccessW开始获取scanSuccess?当我写这样的东西时:
var s = $scope.scanSuccessW;
总是指scanSuccessW(包装器)而不是包装方法;有没有办法在javascript上解包函数?
答案 0 :(得分:2)
执行该函数,而不是获取对它的引用,因为它返回$scope.scanSuccess
函数。
var s = $scope.scanSuccessW();
// ^^ use parenthesis to execute it