Controller runs before .run


#1

Hello i have this issue, i declare a localstorage variable like this:

.run(function($ionicPlatform, $rootScope, $localstorage) {
  $ionicPlatform.ready(function() {
    
    $localstorage.setObject('global', {
        urlService: "http://www.url-to-go.com/",
        rangoDistancia:  0.089831
        });


    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);

    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

it supose when first run and when the platform is ready set the variable, then the controller can read the value, but is empty, i need to close the app and open again and then the values are set, please if some one can tell me what i’m doing wrong, thanks.