I’ve two states in the App 1) login and 2) home. Login will happen only once and then home will launch. Once the login has happened, every time app launch it should load home state. I don’t want to use $state.go in login state. Is there any other approach that i can do this in startup of app?
You could do something in the run part of your module:
if ( $localStorage.loggedIn) {
$state.go( 'tab.home' );
} else {
$state.go( 'login' );
}
Or, you could use the $urlRouterProvider.otherwise (what I would recommend):
// Example of using function rule as param
$urlRouterProvider.otherwise(function($injector, $location){
//perform the check and return '/login' or 'tab.home'
});
should i write that in app.config ? or in “login” controller ?
THe first should go in your app.run block, the second in app.config