我非常渴望帮忙。AngularJS - 从函数中调用http调用中的变量?
我有一个看起来像这样的功能:
$scope.getData = function(id)
{
$http.get('/url' + id).success(function (data) {
return data.a.b.c;
});
};
现在我在其他功能我有这样的事情:
$scope.obj= {};
$scope.obj.name = $scope.user.displayName;
$scope.commentObj.id= $scope.id;
$scope.obj.blah = blah;
$scope.obj.otherDataThing = $scope.getUserProfileData($scope.commentObj.userId);
现在这个变量从未得到设定,当我邮寄到url来创建mongo中的实际数据对象。它只是不显示。我知道它必须做到同步性,但我无法弄清楚。帮帮我!
在此先感谢
我有一个额外的点,比如$ scope.myObj.something,当我尝试这个或任何东西。东西没有设置:(任何想法? – Jerry