Setting initial screen in AngularJS and Ionic Framework

I want to set initial screen in my ionic framework application depending on the fact of user being logged in.

in angular.module.config section I do it using the following approach:

if (window.localStorage.getItem("userKey") != null)
   $urlRouterProvider.otherwise('/tab/content');
else
   $urlRouterProvider.otherwise('/sign-in');

Is it the right approach?

Thank you.

No, it is not. To redirect the user you need to use $location.path.

if (window.localStorage.getItem("userKey") != null)
   $location.path('/tab/content');
else
   $location.path('/sign-in');

You can perform this check into the .run part of your program and redirect your user with ui-router statements such as :

if (window.localStorage.getItem("userKey") != null)
   $state.go('tab.content'); // if your named your state like that
else
   $state.go('signin'); // if your named your state like that