$ionicplatform shared data

hi everyone,

i have some doubt about this “main” variable. standing to my actual knowledge $ionicplatform is the main function. i have a plugin that read the imei, i called this plugin inside this function in this way :

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
if (window.StatusBar) {
// org.apache.cordova.statusbar required
function callback(imei){
return imei;

now it would be nice to access the variable imei, inside my app, how i can do this? simply writing “return imei” does not works.i thought that i may create a service that will handle all “device” stuff ( id, camera, geolocation) something like this may works?

.factory('IMEI', function($ionicPlatform){

passing the $ionicplatform to the service?

thanks in advance,


Its always better practice to create a separate factory for such actions. Or try using $window.localStorage.

you mean in this way?..in the doc pages i’ve seen something about the state to pass data whitin the app

Please refer here http://learn.ionicframework.com/formulas/sharing-data-between-views/