[英]$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>
From Button i am calling the function从按钮我调用函数
$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!");
}
);
};
I am getting Api response but it is not being updated in $scope.records variable .我收到了 Api 响应,但它没有在 $scope.records 变量中更新。
Make sure your view is in the same scope as $scope.records
, it must be something very silly!确保您的视图与$scope.records
处于同一范围内,这一定是非常愚蠢的事情! Seems like your controller and your view are not the same.似乎您的控制器和您的视图不一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.