Routing automatically redirects


I fixed this, but I’m posting this because it may be useful for someone else plagued with a similar problem.

TL;DR - using hrefs instead of ui-srefs in my tabs template fixed the problem.

I still don’t what caused the issue, but I’ve managed to find a fix.

I have a moderately complex routing / state setup using a top level app state and a number of branching states under that, like below (to troubleshoot, I replicated the problem with a very VERY simple state setup, so complexity wasn’t the issue):

- app /app (abstract)
-- app.start /app/start (abstract)
--- app.start.welcome /app/start/welcome
--- app.start.register /app/start/register
--- app.start.signin /app/start/signin
--- /app/tab (abstract)
--- /app/tab/compose
--- /app/tab/messages  (DEFAULT STATE)
--- /app/tab/me

As indicated - is the default state that I set using $urlRouterProvider.otherwise

What was happening whenever I started the app, rather than going to the default state, the navigation would automatically load the first non-abstract state in the config block - e.g. app.start.welcome.

In my tabs template I was linking off the tabs using ui-sref, e.g. ui-sref=‘app.start.signin’

That was a mistake - changing them to hrefs fixed it, e.g. href=‘app/start/signin’

I’m not sure why this was an issue and how using hrefs fixed it, but it seems to be working.