I want to redirect to the login screen when no UABGlobalAdminId in my storage else home screen and for that, I used $urlRouterProvider.otherwise but it's not working fine.When I try debugging the console is not reaching it.Can anyone please suggest help.Thanks.
I have this in my app.js,
$stateProvider
// Home
.state('home', {
url: '/',
templateUrl: 'app/templates/home.html',
controller: 'homeCtrl'
})
.state('login', {
url: '/login',
templateUrl: 'app/templates/login.html',
controller: 'loginRegCtrl'
})
$urlRouterProvider.otherwise(function($injector, $location){
var state = $injector.get('$state');
if(localStorage.getItem('UABGlobalAdminId')){
state.go('home');
} else {
state.go('login');
}
});