2
I have the following code:
.controller('cadastroCtrl', ['$scope', '$stateParams', '$http', function ($scope, $stateParams, $http, $cordovaSQLite, $window, $state) {
$scope.emailCli = [];
$scope.emailPro = [];
$scope.cadastrar = function(usuario){
$http.post("http://ec2-54-68-29-61.us-west-2.compute.amazonaws.com/auth/register", usuario).success(function(response){
var name = response.user.name;
var email = response.user.email;
var id = response.user.id;
var is_professional = response.user.is_professional;
if(typeof(Storage) !== "undefined"){
if(is_professional == true){
localStorage.setItem('userPro', name);
$scope.emailPro = localStorage.setItem('emailPro', email);
localStorage.setItem('idPro', id);
console.log('Professional');
$state.go('menuProfissional');
}else{
localStorage.setItem('userCli', name);
$scope.emailCli = localStorage.setItem('emailCli', email);
localStorage.setItem('idCli', id);
console.log('Client');
$state.go('menuCliente');
}
}else{
console.log("Desculpe, mas o navegador nao possui suporte a Web Storage.");
}
})
}
}])
And on route.js
.state('menuCliente', {
url: '/menuCliente',
templateUrl: 'templates/menuCliente.html',
controller: 'menuClienteCtrl'
})
.state('menuProfissional', { url: '/menuProfissional', templateUrl: 'templates/menuProfissional.html', controller: 'menuProfissionalCtrl' })
And the following error warning appears on the console:
Cannot read Property 'go' of Undefined
What am I doing wrong?
Thanks man, that’s right.
– GustavoSevero
+1 The answer should be accepted.
– Not The Real Hemingway
@Gustavosevero I’m glad it worked!
– OnoSendai