hi everyone, I need your help I have a simple code
var globalvar = 0; // this is my variable global
// this is my controller
zupaios.controller(‘lista’,function($scope){
var timestore = zupafactoryio.ZupaTimeStore(id); // show my timestore
timestore.then(function(anstime){
console.log(anstime.data);
anstime.data.forEach(function(resp){
if( resp.id_category == id){
if( dias[store_day] == resp.day_name){
if( resp.open < store_complete && resp.close > store_complete ){
globalvar = 1; // open store
}
}
}
});
});
/// the problem is the globalvar not working, when out of the foreach the var globalvar have to value zero,
/// and not take val 1
if( globalvar == 1 ){
console.log('cool the var global working '+globalvar);
}else{
console.log(‘the var globalvar not working’);
}
});
when out of the bucle foreach the var globalvar not working.
please why not working my var global, I don’t understand please helpme