Having an issue with my controller that fetches data from a service.
After receiving the data in the controller, I'm using $scope to pass it to the view.
Strange behavior - console.logs inside the 'then' function display the data correctly. However, outside of it, when I try to access $scope.data, it shows up as an empty object.
Could there be an error in my code?
(function() {
angular
.module("eplApp")
.controller("tableCtrl", TableController);
TableController.$inject = ['httpService', "$scope"];
function TableController(service, $scope) {
var apiTableUrl = "http://api.football-data.org/v1/soccerseasons/426/leagueTable";
$scope.data = {};
service.getListFromUrl(apiTableUrl).then(function(data) {
$scope.data = data;
console.log($scope);
console.log($scope.data);
});
console.log($scope);
console.log($scope.data);
}
})();