I have a global variable which I need to update after http get call. After update I need to pass this updated variable to other function. I can't understand what is the best way to do this. Here is 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
};
});
Is it possible at all to update global variable after http call?
Thank you for help in advance.
vmhere, or howdataSourceis used, but since you declareddataas a primitive string, it's likely to not work as expected, especially sinceresponse.dataappears to be JSON....