1
After registering, I want to temporarily put some data in localStorage, but I’m not getting.
Follows my code:
app.controller('cadastroCtrl', ['$scope', '$stateParams', '$http', '$cordovaSQLite', '$window', '$state', function ($scope, $stateParams, $http, $cordovaSQLite, $window, $state) {
$scope.email = [];
$scope.cadastrar = function(usuario){
$http.post("http://vigilantescomunitarios.com/serviapp/api_gustavo/register.php", usuario).success(function(response){
var nome = response.nome;
var email = response.email;
var id = response.idusuario;
var is_professional = response.prof;
if(typeof(Storage) !== "undefined"){
if(is_professional == 1){
$window.localStorage.setItem('userPro', nome);
$scope.email = $window.localStorage.setItem('emailPro', email);
$window.localStorage.setItem('idPro', id);
console.log('Profissional');
$state.go('menuProfissional');
}else{
$window.localStorage.setItem('userCli', nome);
$scope.email = $window.localStorage.setItem('emailCli', email);
$window.localStorage.setItem('idCli', id);
console.log('Cliente');
$state.go('menuCliente');
}
}else{
console.log("Desculpe, mas o navegador nao possui suporte a Web Storage.");
}
})
}
}])
Not getting why? Makes some mistake?
– Jéf Bueno
Pq I check in the "Application" tab of the Chrome console and nothing appears in "Local Storage", where it usually appears.
– GustavoSevero
Do you have any idea @jbueno?
– GustavoSevero
Make sure you are not associating any Undefined value in localStorage, in which case it is not saved at all. See if the variables name, email and id are not Undefined
– Rodolfo Jorge Nemer Nogueira
No, @Rodolfojorgenemernogueira, even that does not appear.
– GustavoSevero
Are you sure you’re getting into ifs?
– Jéf Bueno