我想调用一个函数,函数名称存储在一个变量中,但是它给出了错误。我正在尝试调用函数uploadDocumentCallback
,但其名称存储在变量
$scope.uploadDocumentCallback(data,status,headers,config); //its working fine if i'm passing callback function name directly.
$scope.callback = "uploadDocumentCallback"; //this is my variable where I store function name
var callbackFunction = $scope.callback;
$scope.callbackFunction(data,status,headers,config); //not working
callbackFunction(data,status,headers,config); //not working
$scope.callback(data,status,headers,config); //not working
请建议我如何实现这一目标?
答案 0 :(得分:0)
我设法让它工作
$scope[$scope.callback](data,status,headers,config);