私のコントローラは、次のコードがあります。Angularjsスコープオブジェクトが空白なのはなぜですか?
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);});
をしかし、私はコンソールに$scope.allLogs
を書くときには、空のオブジェクトを示しますが、私はconsole.log($scope);
を行うとallLogs配列を表示したとき、私はデータを見ることができます。
response.dataは次のとおりです。
[
{"id" : 001, "name" : "name", "age" : 20},
{"id" : 002, "name" : "name", "age" : 21},
{"id" : 003, "name" : "name", "age" : 22},
{"id" : 004, "name" : "name", "age" : 23}
]
私が間違って何をしているのですか?