0

I'm setting the initial state when first entering the app with a simple condition (i'm fully aware it also prevents deep linking .. thats OK).

.run(function($state, browserFactory) {

    if (browserFactory.isSupported()) { 
        $state.go('browser-unsupported');
    } else { 
        $state.go('welcome');
    }
}

This is working fine.

But, if I set an otherwise rule it will always follow that rule. For example, if I set

.config(function($urlRouterProvider) {
    $urlRouterProvider.otherwise('/welcome');
}

It will always end up at /welcome.

Is there any way around it or maybe a better way to set an initial route based on a condition and have an otherwise rule?

haki
  • 9,389
  • 15
  • 62
  • 110
  • Possible duplicate of [Otherwise on StateProvider](http://stackoverflow.com/questions/16793724/otherwise-on-stateprovider) – Estus Flask Oct 13 '15 at 17:55

1 Answers1

0

The only solution I can think of is to do this logic in a main controller so even if you're redirected to welcome, it will change to the desired route after passing the if statement.

Basically you shouldn't put to much code in you app.run.

atardadi
  • 429
  • 2
  • 5
  • 14