I need to display either a Login or Logout button based on the value of a $rootScope variable. Currently, only the Logout button is showing up in the li tag below. I have specific actions that should occur after certain events:
After Logging In:-
$rootScope.userData = response.userdata; //response.userdata is an Object
After Logging Out:-
delete $rootScope.userData;
$rootScope.userData = null;
In the Controller:-
console.log($rootScope.userData); //Object {}
Html Code:-
<li ng-if="$root.userData == null"><a href="#/login"><i class="fa fa-lock"></i> Login</a></li>
<li ng-if="$root.userData != null"><a href="#/logout"><i class="fa fa-lock"></i> Logout</a></li>