获取异步回发作用域函数上的JavaScript错误

获取异步回发作用域函数上的JavaScript错误,javascript,angularjs,Javascript,Angularjs,我在angular.min.js上报告了以下错误 0x800a1391-JavaScript运行时错误:“错误”未定义 使用以下代码: Javascipt: function Sucess() { //close } function Save() { var e = document.getElementById('FormDiv'); scope = angular.element(e).scope(); scope.Apply(Sucess) } 我

我在angular.min.js上报告了以下错误

0x800a1391-JavaScript运行时错误:“错误”未定义

使用以下代码:

Javascipt:

function Sucess() 
{
    //close
}

function Save() 
{
    var e = document.getElementById('FormDiv');
    scope = angular.element(e).scope();
    scope.Apply(Sucess)
}
我的角度范围功能:

function RolesCtrl($scope, $http, $location) 
{
    $scope.Apply = function (CallBackSucess) {

    var userId = getQSP('uid', decode(document.URL));
    $http({
    method: 'POST', url: 'MultiRole.aspx/Apply',
    data: {}
    }).
    success(function (data, status, headers, config) {
        // this callback will be called asynchronously
        CallBackSucess();
        $scope.f = data.d;
        }).
    error(function (data, status, headers, config) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
    $scope.name = 'error';
    })
    }
}
在发出抛出错误的调用之前,一切似乎都正常工作:

0x800a1391-JavaScript运行时错误:“错误”未定义


callbackuces
参数被传递给
.Apply()
方法。它不会传递给
.success()
方法-它们是具有单独作用域的链接方法。因此,在
.success()
回调函数中,尝试调用时未定义
callbacksuccess()
,因此会出现错误

另外,你真的想把
suces
拼写错误吗

仅供参考,我必须这样格式化您的代码,以便查看实际发生的情况:

function RolesCtrl($scope, $http, $location) {
    $scope.Apply = function (CallBackSucess) {
        var userId = getQSP('uid', decode(document.URL));
        $http({
            method: 'POST', 
            url: 'MultiRole.aspx/Apply',
            data: {}
        }).success(function (data, status, headers, config) {
            // this callback will be called asynchronously
            CallBackSucess();
            $scope.f = data.d;
        }).error(function (data, status, headers, config) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
            $scope.name = 'error';
        })
    }
}