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 no route.js
.state('menuCliente', {
url: '/menuCliente',
templateUrl: 'templates/menuCliente.html',
controller: 'menuClienteCtrl'
})
.state ('menuProfessional', { url: '/ menuProfessional', templateUrl: 'templates / menuProfessional.html', controller: 'menuProfessionalCtrl' })
And the following error message appears in the console:
Can not read property 'go' of undefined
What am I doing wrong?