I suggest to use a service.
If you want stock persistant data, i suggest to use this https://github.com/Zmetser/localstorageservice
This module uses localStorage
(documentation) (or cookies if you use IE)
Untested example:
The service
myApp.service('controllerSharingData', function() {
var __variables = {};
return {
get: function(varname) {
return (typeof __variables[varname] !== 'undefined') ? __variables[varname] : false;
},
set: function(varname, value) {
__variables[varname] = value;
}
};
});
Controllers
myApp.controller('IndexCtrl', function($scope, controllerSharingData) {
controllerSharingData.set('toto', 'hello world');
});
myApp.controller('ListCtrl', function($scope, controllerSharingData) {
alert(controllerSharingData.get('toto'));
});