这是我的代码:
$scope.userDetails = function(userId, type) {
ajax.get(orginalData.blockData.USER_BASIC_DETAILS + userId, $scope.getUserDetailsCallBack)
}
$scope.getUserDetailsCallBack = function(result) {
console.log(result)
$scope.empdetails = result.data.record;
}
我需要将type
传递给callback
方法。如果我这样通过,则会出现Cannot read property 'record' of undefined
错误。
$scope.userDetails = function(userId, type) {
ajax.get(orginalData.blockData.USER_BASIC_DETAILS + userId, $scope.getUserDetailsCallBack(type))
}
$scope.getUserDetailsCallBack = function(result, type) {
console.log(result,type)
$scope.empdetails = result.data.record;
}
如何通过?
答案 0 :(得分:2)
$scope.userDetails = function(userId, type) {
ajax.get(orginalData.blockData.USER_BASIC_DETAILS + userId, function (result) {
$scope.getUserDetailsCallBack(result, type)
});
}