Redirect to dashboard if user is logged in with Ionic
<p>I am trying to make my app direct to the dashboard on initial load if the user has authenticated with Firebase already. </p>

<p>Basically, if the user has logged in. I want them to see the dashboard instead of the login page when they open the app on their phone. </p>

<p>I've tried to place this in my <code>app.run()</code>. It works and does what I want but it results in an ugly error </p>

<pre><code>Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: []
</code></pre>

<p>This runs about 20 times before stopping.</p>

<p>My code in the <code>app.run()</code> function: </p>

<pre><code>$rootScope.$on("$stateChangeStart", function(event, next, current) {
  if($rootScope.user)
  {
    if(next.name === 'login')
  {
    $state.go('tab.dash');
    event.preventDefault();
  }
  else
  {
    console.log('Do Nothing, User Is Not Logged In');
  }
}
});
</code></pre>

<p>How do I do this without getting any errors?</p>