title: Is there a way to prevent the initial state from loading when my angularjs app starts up?
body: <p><strong>Background</strong></p>
  
  <p>My app needs to make a request to the server to verify whether or not the user has an authenticated session, before the first state is loaded. As depending on on the url, the user may need to be redirected to the login page.</p>
  
  <p>i.e if the initial url is <code>myapp.com/#/profile</code> and the user doesn't have a pre-existing authenticated session, they'll be redirected to <code>myapp.com/#/login</code></p>
  
  <p><br/>
  <strong>Problem</strong></p>
  
  <p>I have logic in place to deal with this situation, but immediately after the session data request is made to the server and before it completes, the initial state change is triggered and the page loads and displays, before the server responds</p>
  
  <p><br/>
  <strong>Possible Solutions</strong></p>
  
  <p>1) I'm using django as my backend, so could just remove the initial server request from the app and pass the data direct to the app in the django template. Either through</p>
  
  <ul>
  <li><p>ng-init of the main controller - although i've read that this is a
  bad idea, as it's not it's intended usage</p></li>
  <li><p>Or in a script tag in the django template - which i'm loathe to
  do, as i'd rather keep all my application logic seperate in js files</p></li>
  </ul>
  
  <p>2) Listen for the initial $stateChangeStart, cancel it and then call $state.reload() once the server requests completed</p>
  
  <p><br/>
  <strong>Question</strong></p>
  
  <p>It would seem to me to be a fairly common requirement to fulfill certain criteria before the initial state change occurs, so i'm wondering if i've missed something in the docs and there's already an inbuilt way to deal with this scenario? </p>
  
  <p>Or is there a way to deactivate the $urlRouterProvider/$stateProvider to prevent the initial state change from occurring?</p>