I'm building an application that has an index.html and the views in separate files being rendered within the ng-view of the index.
In this index I have a footer that I would like it to disappear when the user is forwarded to the home view after login.
The problem is that the ng-hide of this footer is not getting the current value of the "authenticated" variable after the login, which causes the user to be forwarded to home, but with the footer still appearing. p>
How do I make the variable to be updated and footer disappear? For variables that are used within the view, ng-hide / ng-show works correctly, it just is not working for this static part of the index.
index.hmtl
<html ng-app="gameApp">
<head>
<!-- referências de css e scripts -->
</head>
<body>
<div id="main" class="container">
<div ng-view></div>
</div>
<footer ng-hide="autenticado">
teste
</footer>
</body>
</html>
app.js
var ggApp = angular.module('gameApp', ['ngRoute', 'servicoLogin']);
// configure our routes
ggApp.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'pages/login.html',
controller : 'usuarioController',
controllerAs : 'loginCtrl'
})
// route for the about page
.when('/cadastro', {
templateUrl : 'pages/cadastroUsuario.html',
controller : 'usuarioController',
controllerAs : 'loginCtrl'
})
// route for the contact page
.when('/home', {
templateUrl : 'pages/home.html',
controller : 'homeController',
controllerAs : 'homeCtrl'
})
.otherwise({
redirectTo: '/'
});
});
userController.js
ggApp.controller("usuarioController", ['$scope', 'Login', 'Cadastro', 'VerificaEmail', '$location',
function($scope, Login, Cadastro, VerificaEmail, $location) {
$scope.erro = false;
$scope.mostraMensagem = false;
$scope.mensagemErro = "teste";
$scope.autenticado = false;
this.usuarioLogin = {};
this.realizaLogin = function() {
var usuario = {
email: this.usuarioLogin.login,
senha: this.usuarioLogin.senha
}
var promise = Login.login(usuario);
promise.$promise.then(
function success(usuario)
{
if (usuario.id > 0) {
$location.path("home");
$scope.autenticado = true;
} else {
$scope.erro = true;
$scope.mensagemErro = "Usuário não encontrado!";
};
$scope.mostraMensagem = true;
$scope.setClasseErro();
},
function error(value) {
$scope.erro = true;
$scope.mostraMensagem = true;
$scope.mensagemErro = "Erro: " + value.status;
}
);
};
}]);