[英]$scope variable inside the function is not getting updated in angular js
<button class="button button-primary"
ng-click="editSchedule(controlCenter.selected)">
Edit Schedule
</button>
從按鈕我調用函數
$scope.records = [];
$scope.editSchedule = function(data) {
var s = "/api/v1/controlcenter/sitegroups?";
for (var i = 0; i < data.length - 1; i++) {
s += "ids=" + data[i]._id + "&";
}
s += "ids=" + data[data.length - 1]._id;
$http({
method: "GET",
url:s,
}).then(
function successCallback(response) {
$scope.records = response.data;
console.log("angular api call");
console.log($scope.records);
},
function errorCallback(response) {
alert("Error. Try Again!");
}
);
};
我收到了 Api 響應,但它沒有在 $scope.records 變量中更新。
確保您的視圖與$scope.records
處於同一范圍內,這一定是非常愚蠢的事情! 似乎您的控制器和您的視圖不一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.