I have successfully populated $scope with data using a get call:
httpGetAsync("myUrlWasHere", getBlogPosts, $scope);
The console outputs the data when I print console.log($scope)
:
https://i.sstatic.net/SkDl9.png
However, when I try to access it using console.log($scope.blogPosts)
, it returns undefined:
https://i.sstatic.net/R56N5.png
The callback function looks like this:
function getBlogPosts(param, $scope) {
$scope.blogPosts = JSON.parse(param);
}
My goal is to pass the array inside blogPosts.items
to Angular for use with ng-repeat
.
Here is the controller code snippet:
websiteApp.controller('BlogController', function BlogController($scope) {
console.log("blog loaded");
httpGetAsync("myUrlHere",
getBlogPosts,
$scope);
//console.log($scope);
console.log($scope.blogPosts);
});
These are just console.log statements used to provide screenshots. How can I address this issue asynchronously?