Maybe this is simple, but having a hard time understanding how to setup. Basically I want to start my app in “blank” mode so I can basically had the end user sign up to use the app. Then once they are signed in I want the app to have tabs. Next tIme I load the app I will check to see if the user is signed in already and automatically start in with tabs. How do I accomplish this?
The simplest way is to use Local Storage. You can save data locally and check them on app start.
Then you set a var and check it on app restart.
If the user is logged in, then you could do:
$location.path('/PATH/HERE').replace();
I use $location.path().replace()
because, I don’t want to let the user back to the intro when it gets skipped.
But I am looking for a better way, because the blank page sometimes gets rendered before I could redirect. So, not the perfect solution.
I think a cleaner solution would be to include a service to the provider-state, which refers to the tabs-page in the resolved section;
$stateProvider.state('myState', {
resolve: {
isLoggednIn = checkLoggedInSvc();
}
}
This is resolved BEFORE the controller is initialized (see https://github.com/angular-ui/ui-router/wiki#resolve). That way you could change the URL there and prevent the blank page from showing up. I also would not use .replace()
, but rather $state.go()
because I think it is faster (at least it should be).
Greetings
You could try something like this.