I read data from sqlite in angular run block and store the data in $rootScope, but while I try to read it in controller, it turns out that the data does not exists.The strange is in view the data already shows up.Here is the code like:
angular.module('starter',['ionic', 'starter.controllers', 'starter.services','ngCordova'])
.run(['$ionicPlatform', '$rootScope','$cordovaSQLite'],function ($ionicPlatform, $rootScope, $cordovaSQLite){
$ionicPlatform.ready(function() {
var db = $cordovaSQLite.openDB({name:"ISHOP.db"});
var query = "SELECT * FROM operator";
$cordovaSQLite.execute(db,query).then(function(res){
var operator = angular.fromJson(res.rows.item(0));
$rootScope.CURRENT_OPERATOR = operator;
},function(err){
});
}
})
.config(//code for route)
controller:
angular.module('starter.controllers', [])
.controller('LoginCtrl',function($scope,$rootScope,$state){
***//can not acess $rootScope.CURRENT_OPERATOR here, why?***
})