Skip to content

Instantly share code, notes, and snippets.

@fotoflo
Last active August 29, 2015 14:00
Show Gist options
  • Save fotoflo/6b69635b25375253fac8 to your computer and use it in GitHub Desktop.
Save fotoflo/6b69635b25375253fac8 to your computer and use it in GitHub Desktop.
Service:
UserService.getUser = function(){
return $http( { method: 'GET', url: '/users/me', cache : true } )
.success(function(results, status){
if( (status!= 200) || (typeof(results) == "undefined") ){
alert('logged out!');
location.href = "/index.html";
}
});
}
Controller:
userService.getUser().then(function(promise){
$scope.user = promise.data;
$scope.$apply();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment