you can exchange data between two controllers by using same service
example:
myapp.controller('myController', ['$scope','MyService'
function ( $scope,myService) {
var obj={};
obj=myService.setObject();
$scope.obj=obj;
}]);
myapp.controller('myController2', ['$scope','MyService'
function ( $scope,myService) {
var obj2={};
obj2=myService.setObject();
$scope.obj2=obj2;
}]);
myapp.factory('MyService', function(){
var obj = {};
_setObject = function (value) {
obj.value = value;
return obj;
}
_getObject = function () {
return obj;
}
return {
setObject : _setObject ,
getObject :_getObject
}
});
controllers contains the reference of service object when one controller change the object the other controller object automatically get changed because they shared the same reference of that service object