I have an object that I would like to share with other Controllers
, I thought in two ways, the first would be to use $rootScope
and in the other to use a Service
. I opted for the second way and created the following service:
AuditoriaAPP.factory('Service', function() {
var Service = {
solicitacoes: {}
};
return Service;
});
On the 1st Controller, which is where my object I want to share I do this:
Service.solicitacoes = solicitacao;
So far so good, the object is successfully assigned and can retrieve it in the 2nd Controller
:
$scope.solicitacoes = Service.solicitacoes;
The problem is that when I refresh the page the object becomes empty. How can I make a communication between these Controllers
without the object being empty when updating the page?