My controller has the following code:
app.controller("weeklyLogViewer", function ($scope, $http){
$scope.allLogs = {};
$http({
method: 'POST',
url: '../Utilities/WeeklyLog.php',
data: $scope.dateSelected,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(function successCallback(response)
{
$scope.allLogs = response.data;
});
console.log($scope.allLogs);});
But when I write $scope.allLogs
to console it shows empty object but when I do console.log($scope);
and view the allLogs array I can see the data.
The response.data is:
[
{"id" : 001, "name" : "name", "age" : 20},
{"id" : 002, "name" : "name", "age" : 21},
{"id" : 003, "name" : "name", "age" : 22},
{"id" : 004, "name" : "name", "age" : 23}
]
What am I doing wrong?