I have the following code:
$http({
method: 'GET',
url: 'http://localhost:8080/getStuff'
}).then(function successCallback(response) {
$scope.stuffData= response.data.length;
}, function errorCallback(response) {
});
console.log("amount is:" +$scope.stuffData);
});
In this instance, my log gives:
amount is:undefined
Some other SO questions suggest running $scope.$apply to make my scope persist. To this I get the following error:
angular.js:13920 Error: [$rootScope:inprog] $digest already in progress
What is the correct way to persist my scope? I.E what is the correct way to assign values of a get request to a scope variable?