In my ionic app I have the app.run function and a device ready function inside it:
app.run(function($rootScope, $ionicPlatform, $cordovaPush) {
document.addEventListener("deviceready", function(){
}, false);
})
When I declare a rootScope variable in the run function like below the variable is available in all controllers.
app.run(function($rootScope, $ionicPlatform, $cordovaPush) {
$rootScope.myvariable = 'teststring';
document.addEventListener("deviceready", function(){
}, false);
})
When I place the rootScope variable inside the deviceready function the rootScope variable is not available anymore
app.run(function($rootScope, $ionicPlatform, $cordovaPush) {
document.addEventListener("deviceready", function(){
// I need this variable here because it's a value generated by a function that only works inside the deviceready function
$rootScope.myvariable = 'teststring';
}, false);
})
How can I make the rootscope variable inside the deviceready function available for all my controller ?