I've developed a function expression that I've linked to scope. The purpose of this function is to trigger an $http request, retrieve a specific property, and then deliver it.
$scope.getRequestDigest = function () {
var url = urlParams['SPAppWebUrl'] + '/_api/contextinfo';
$http.post(url)
.success(function (res) {
return res;
});
}
However, when I invoke $scope.getRequestDigest(), it simply gives back undefined, most likely due to the fact that the ajax call hasn't finished yet. Is there a way to postpone the return until the $http request has completed? I've attempted using the .success() promise without success.