グローバル変数として$scope.participants = []
があります。私の問題は、以下の関数を呼び出した後、別の関数でこの変数を使用したときです。 $scope.participants
は空です。しかし、私がresponse.data
をチェックしたときではありません。
$scope.getParticipants = function(seminar_id,seminar_name,seminar_code) {
$http({
method: 'GET',
dataType: 'JSON',
params: { 'seminar_id' : seminar_id },
url: 'getParticipants'
}).then(function(response) {
$scope.participants=response.data;
});
}
コンソールのエラーが表示されます – Sajeetharan
'$ http'は非同期呼び出しです。 '$ http'がデータを返す前に' $ scope.participants'は空です。 –
これで問題が解決するかどうかを確認してください。 http://stackoverflow.com/questions/18421830/how-to-wait-till-the-response-comes-from-the-http-request-in-angularjs –