When using $http.post in angular to request data, I found that the data after each request is the updated data when viewed in the console Network, but in $http.post (data address, parameters). success(function(response){$scope.datas=response.data;
console.log(response.data.vote_options) //This is the printed data but it is different from the data viewed in the console (a certain parameter value) Inconsistent, why??}), please see the specific code below:
var voteposturl="/Api/Share/GetVoteInfo";
var votepostparameter="&nid="+nid+"&vote_id="+$scope.voteid;
$http.post(voteposturl,votepostparameter).success(function(response){
$scope.datas=response.data; //总体数据
console.log(response.data.vote_options) //现打印其数据结构中具体的一个数组数据
console.log(response.data.vote_options[0].is_voted) //现打印其数据结构中具体的一个数组数据里面具体一条数据中的参数值,该参数值与在控制台查看的接口那里的数据又是保持一致,不知道为什么会这样
})
Please see the data comparison after the request:
This is the printed data //console.log(response.data.vote_options)
Does anyone know what causes this? Is it because $http is cached? Or is it because of other reasons?
Change your browser and see if the problem is the same. Chrome has some bugs
It is likely that its value has been modified in some places in your code.
Print response.data above $scope.datas = response.data;. Check if it is consistent with the console
Maybe you performed data operations in some places you didn’t pay attention to. Angular is not good at this. If you move it slightly, everything will change.