Skip to content

Instantly share code, notes, and snippets.

@jungheelee
Created April 20, 2016 06:33
Show Gist options
  • Save jungheelee/aa69ed30502fb768d9b60ea75e467b66 to your computer and use it in GitHub Desktop.
Save jungheelee/aa69ed30502fb768d9b60ea75e467b66 to your computer and use it in GitHub Desktop.
function config($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider) {
// Configure Idle settings
IdleProvider.idle(5); // in seconds
IdleProvider.timeout(120); // in seconds
$urlRouterProvider.otherwise("/dashboards/dashboard_1");
$stateProvider
.state('login', {
url: "/login",
templateUrl: "login.html",
controller: LoginCtrl,
authenticate: false
})
.state(.......)
}
angular
.module('inspinia')
.config(config)
.run(function($rootScope, $state, UserService) {
$rootScope.authenticated = false;
console.dir($rootScope);
console.dir($state);
console.log(UserService);
$rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams) {
if(toState.authenticate == true && !UserService.isLogged){
$state.go("login");
event.preventDefault();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment