I am stuck at hiding and showing login/logout buttons at navbar. I am setting some cookies at loginCtrl
belongs to login.html
. And getting those cookies in homeCtrl
which belongs to home.html
. Here is my code;
.controller("loginCtrl", function($scope, $rootScope, $cookies, $state) {
$scope.login = function () {
Auth.$authWithPassword({}).then(function() {
$rootScope.bekmez = true; // Using this in home.html > navbar.
$cookies.put('Some', true);
$state.go('baba.ana.manga');
})
.controller("homeCtrl", function($scope, $cookies) {
$scope.bekmez = $cookies.get("Some");
)}
My navbar:
<li ng-show="bekmez">Username</li>
<li ng-hide="bekmez">Login Button</li>
So i did some googling and find that;
Cookies are only added to the browser on digest.
I dont know what the digest is. So what is the possible solution to my problem?