Avoid using modules in this scenario. The recommended approach is to utilize a service
for sharing persistent data among Controllers.
var ControllerOne = function (someService) {
}
var ControllerTwo = function (someService) {
}
app.service('someService', function(){
this.sayHello= function(text){
return "Service says \"Hello " + text + "\"";
};
});
Alternatively, consider utilizing event
on the scope
.
var ControllerOne = function($scope) {
$scope.$on('someEvent', function(event, data) {
});
}
var ControllerTwo = function($scope) {
$scope.$on('someEvent', function(event, data) {
});
}
$rootScope.$broadcast('someEvent', [1,2,3]);