problem description
after the assignment operation, the contents of the global variable are empty.
the environmental background of the problems and what methods you have tried
Google browser. Using var to define global variables also has no effect.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
$scope.collection= {};
$scope.list={};
$scope.controlMap={};
$scope.initzhanquzhang=function(){
$http({
method:"POST",
url:"Report/ReportSearch",
data:{ReportSearchCode:"getSalesKqDataBuManager3",salesDateStr:$scope.searchData.salesDateStr,kindCode:$scope.kindCode}
})
.success(function(result, status, headers, config){
angular.forEach(result,function(data,index,array){
//collectionkindCodeAndBuName
var buName=data.buName;
var kindCode = data.kindCode;
var kindCodeAndBuName=kindCode+"_"+buName;
$scope.collection[kindCodeAndBuName]=[];
$scope.list[kindCodeAndBuName]=[];
$scope.controlMap[kindCodeAndBuName]=null;
});
$http({
method:"POST",
url:"Report/ReportSearch",
data:{ReportSearchCode:"getSalesKqDataDetailBuManager3",salesDateStr:$scope.searchData.salesDateStr,kindCode:$scope.kindCode}
})
.success(function(result, status, headers, config){
angular.forEach(result,function(data,index,array){
//
var buName=data.buName;
var kindCode = data.kindCode;
var kindCodeAndBuName=kindCode+"_"+buName;
if($scope.collection.hasOwnProperty(kindCodeAndBuName) ){
if(data.longitude && data.latitude ){
$scope.collection[kindCodeAndBuName].push(new BMap.Point(data.longitude,data.latitude));
}
$scope.list[kindCodeAndBuName].push(data);
}
});
alrt(JSON.stringify($scope.list));
/*$http({
method:"POST",
url:"Report/ReportSearch",
data:{ReportSearchCode:"getSalesKqDataBuManager3",salesDateStr:$scope.searchData.salesDateStr,kindCode:$scope.kindCode}
})
.success(function(result, status, headers, config){
angular.forEach(result,function(data,index,array){
var buName=data.buName;
var kindCode = data.kindCode;
var kindCodeAndBuName=kindCode+"_"+buName;
var options = {
size: BMAP_POINT_SIZE_SMALL,
shape: BMAP_POINT_SHAPE_STAR,
color: "yellow",
scale: 0.5
}
if($scope.controlMap.hasOwnProperty(kindCodeAndBuName) ){
$scope.controlMap[kindCodeAndBuName] = new BMap.PointCollection($scope.collection[kindCodeAndBuName], options);
}
});
});*/
});
});
};
$scope.initzhanquzhang();
alert(JSON.stringify($scope.collection));
what result do you expect? What is the error message actually seen?
expect to see a value in the variable. What time sees is {}.