Skip to content

Instantly share code, notes, and snippets.

@kaiohken1982
Created October 23, 2013 16:43
Show Gist options
  • Select an option

  • Save kaiohken1982/7122132 to your computer and use it in GitHub Desktop.

Select an option

Save kaiohken1982/7122132 to your computer and use it in GitHub Desktop.
Check login angularjs using rootScope
.run(['$rootScope', 'LoggedInLoader', 'CategoriesLoader', 'LocationsLoader',
function($rootScope, LoggedInLoader, CategoriesLoader, LocationsLoader) {
// All GLOBAL here
$rootScope.redirectionDelay = 2500;
$rootScope.checkedLogged = false;
$rootScope.logged = false;
$rootScope.username = '';
$rootScope.check = function() {
$rootScope.resource = new LoggedInLoader({});
$rootScope.resource.then(function(data) {
if(!data.logged) {
$rootScope.logged = false;
} else {
$rootScope.logged = true;
$rootScope.username = data.logged;
}
$rootScope.checkedLogged = true;
});
}
$rootScope.check();
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment