I have navbar
which is included in the index.html page
<body>
<div class="container">
<div ng-controller="colaboradorController" ng-include="'public/views/navBar.html'"></div>
<div ng-view></div>
</div>
</div>
</body>
So far so good, in this navBar I have a Data Binding
where I get the logged in user:
<p class="navbar-text usuarioLogado">{{usuarioLogado}}</p>
The controller that is being used is the contributorController, in this controller I have a function that takes the user logged in:
var init = function () {
var temp = sessionStorage.getItem('userLogado');
var viewName = $.parseJSON(temp);
if(viewName != null){
$scope.usuarioLogado = viewName.usuario.nome;
}else{
$scope.usuarioLogado = "";
}
};
And start this function when the page opens:
init();
The problem is that when the page is opened usuarioLogado
is not displayed in NavBar
, it only appears after F5
. I already made a console.log
to see if it is being loaded along with the page and it is loaded. I'm just not able to instantly update this Navbar
being included in my index.html
.
How do I solve this problem?