Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs资源-如何从$save获取响应_Javascript_Angularjs_Angular Resource - Fatal编程技术网

Javascript Angularjs资源-如何从$save获取响应

Javascript Angularjs资源-如何从$save获取响应,javascript,angularjs,angular-resource,Javascript,Angularjs,Angular Resource,我正在保存一些数据,从API中得到正确的响应。在那之后,我将尝试在.$save函数结束后使用这些信息。这是我的密码: auxPostulation = new Postulation($scope.postulation); auxPostulation.$save(null, function(response){ //I get the response and the id value without t

我正在保存一些数据,从API中得到正确的响应。在那之后,我将尝试在.$save函数结束后使用这些信息。这是我的密码:

auxPostulation = new Postulation($scope.postulation);
                        auxPostulation.$save(null, function(response){
                   //I get the response and the id value without trouble.
                            $scope.postulation_id = response.id;
                        },function(error){
                            console.log('erro');
                        });
我想在电话之外使用这种回应,但我打不到。始终获取“$scope.position\u id=undefined”

这个函数是如何工作的


在advanced中感谢您。

假设
块外声明变量
$scope.position\u id
,然后在块内分配它。请注意,如果在调用
$scope.position\u id
时回调尚未完成,则仍可能会得到
未定义的
。您可能需要正确地放置代码以解决该问题,在某些情况下使用
$timeout
或另一个回调