1
I have the following code in the controller
app.controller('loginCtrl', ['$scope', '$stateParams', '$http', '$cordovaSQLite', '$window', '$state',
function ($scope, $stateParams, $http, $cordovaSQLite, $window, $state) {
$scope.clienteId = null;
$scope.clienteNome = null;
$scope.clienteEmail = null;
$scope.profId = null;
$scope.profNome = null;
$scope.profEmail = null;
$scope.logar = function(usuario){
$scope.error = null;
$scope.errors = {};
$http.post("http://vigilantescomunitarios.com/serviapp/api_gustavo/login.php", usuario).success(function(response){
//console.log(response);
if(response == '' || response == [] || response == 'null'){
$scope.msgErro = "E-mail ou senha inválido";
return;
}else if(typeof(Storage) !== "undefined") {
var prof = response.e_profissional;
var id = response.idusuario;
var nome = response.nome;
var email = response.email;
if(prof == 1){
$scope.profNome = nome;
$scope.profEmail = email;
$scope.profId = id;
console.log($scope.profNome);
$state.go('menuProfissional', { "nome": nome, "email": email, "id": id });
}else{
$scope.clienteId = id;
$scope.clienteNome = nome;
$scope.clienteEmail = email;
console.log($scope.clienteNome);
$state.go('menuCliente');
}
}
})
}
}])
And the controller where I’ll get them
app.controller('menuProfissionalCtrl', ['$scope', '$stateParams', 'stateParams', function ($scope, $stateParams, stateParams) {
$state.params.nome;
console.log($state.params.nome);
}])
However, what appears on the console is "Nan"
What I have to fix to get the name, email and id?
Where your route is set
menuProfissional
?– Sorack
.state('menuProfissional', { url: '/menuProfissional/:name/:email/:id', templateUrl: 'templates/menuProfissional.html', controller: 'menuProfissionalCtrl' })
– GustavoSevero
To get the value you just need to use
$stateParams.nome
inside your controller. Test to see if it fits– Sorack