Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49164

Varible Global not woking

$
0
0

@roma35 wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>