[英]Angular $scope variable is empty and not updated after setting it in HTTP GET
我有$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;
});
}
您可以簽出該工作插件 ,您需要等到您的諾言解決。
$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;
$scope.callBack();
console.log(response.data);
});
}
$scope.getParticipants('a','b','c');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.