I'm facing a challenge where I have a global variable that needs to be updated after an HTTP GET call. Once updated, I then need to pass this updated variable to another function. I'm struggling to figure out the best approach for achieving this. Here's the snippet of my code:
app.controller('myCtrl', function($scope, $http) {
var data = '';
$http.get("data.json")
.then(function(response) {
data = response.data;
});
vm.mapOptions = {
controls: {
navigator: false
},
center: [40, -35],
zoom: 3,
layers: [{
style: {
fill: {
color: '#1996E4'
},
stroke: {
color: '#FFFFFF'
}
},
type: 'shape',
dataSource: data
}],
shapeCreated: onShapeCreated,
shapeFeatureCreated: onShapeFeatureCreated
};
});
I'm unsure if it's even possible to update a global variable after an HTTP call. Any advice or guidance would be greatly appreciated.
Thank you in advance for your help.