I have on my controller:
$scope.test= function () {
var list = ["var0","var1","var2","var3"];
var result= 0;
for (var x=0;x<list.length;x++) {
result= result + TestService.loadVariable(list[x])
}
$scope.result = result;
}
and my service is:
loadVariable : function(name) {
return $http({
method: 'GET',
url: "/test/sheet/loadVariable/",
params: {name: name},
}).then(function success(response) {
return response.data;
}, function error(response) {
});
},
The problem is that I always get the result and I think it's because I do not have time to execute the loadvariables methods, any suggestions?