I have the following problem:
I have a service where I create a variable that I will manipulate and send to another controller.
This is my service
app.service("maissaude", [
"$rootScope",
function($rootScope) {
$rootScope.nomeMinimo = ""; //Variável que vou manipular e ler em outro controller
}]);
In this same service I have a method that saves a minimal record in api and returns me the saved user:
minimumRegistration: function(form, doctor) {
maissaude.http.post({
url: "url que vai na api salvar o dado",
data: maissaude.signup.modelMinimum,
callback: {
success: function(data) {
var nomeMinimo = data.name;
$rootScope.nomeMinimo = nomeMinimo;//Atualizo meu nomeMinimo da mesma forma que fiz lá no início do método
$window.location = "/login/#/cadastro/" + data.id;
}
}
});
}
In another controller I read this $ rootScope.nomeMinimo But it does not come with the data that was assigned to it after saving the user, It comes empty the way I said up there;
app.controller("CadastroController", [
"$scope",
"$rootScope",
"maissaude",
function($scope, $rootScope, maissaude) {
console.log("Variável global!!!!!!!!!!!!!!!!!");
console.log($rootScope.nomeMinimo);
}
]);
Someone can tell me what I have to do to be able to read this console, the data I manipulated in the other service. PLease !!