回调比它应该的更早触发(平均堆栈)

Callback fires earlier than it should (Mean stack)

我有两个函数 getCharacterInfo(callback) 和 apply()。我在 getCharacterInfo 中调用 apply() 作为回调,但应用(回调)比它应该触发的早(至少从代码中可以看出)

这是我的代码:

getCharacterInfo(回调)

$scope.getCharacterInfo = function(callback) {
    temp = $http.get('https://eu.api.battle.net/wow/character/' + $rootScope.current_user_realm + '/' + $rootScope.current_user + '?locale=en_GB&apikey=hidden');
    temp.then(function onSuccess(response){
        $scope.charInfo = response.data;
        $scope.charInfo.thumbnail = "https://render-api-eu.worldofwarcraft.com/static-render/eu/" + response.data.thumbnail
        console.log("$scope.charinfo = " + $scope.charInfo)
        console.log("response.data = " + response.data)
        if(callback) {
            callback();
        }
    })
}

申请()

$scope.apply = function() {
            $scope.newApplication.charName = $scope.charInfo.name;
            $scope.newApplication.realm = $scope.charInfo.realm;
            $scope.newApplication.armoryLink = 'http://eu.battle.net/wow/en/character/'+ $scope.charInfo.realm + '/'+ $scope.charInfo.name +'/advanced'
            console.log($scope.newApplication)
            applicationsService.save($scope.newApplication, function(){
                $scope.applications = applicationsService.query();
                $scope.newApplication = null;
            });
    };

函数调用来自 HTML-提交表单

<form ng-Submit="getCharacterInfo(apply())">

我得到的错误是在 apply() 中,控制台告诉我 $scope.charInfo 未定义。此外,characterInfo 中的 console.log() 永远不会触发,我认为它们应该触发?

我错了什么?

传递不带括号的 apply 参数:

<form ng-submit="getCharacterInfo(apply)">

否则,首先执行函数 apply,然后将其结果传递给 getCharacterInfo 函数。