div with ng-show not updating after ajax call
The problem is that you update the variable (user_logged_in
) outside of the Angular context, so Angular knows nothing about it (until you refresh the page for example).
You should wrap the body of your callback in $scope.$apply()
:
$apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular framework we need to perform proper scope life cycle of exception handling, executing watches.
(emphasis mine)
BTW, you wouldn't face the same problem if you performed your request using the $http
service, because it is Angular-context-aware.