Otherwise on StateProvider

Adelin picture Adelin · May 28, 2013 · Viewed 95.5k times · Source

Using angular-ui-router, How can I use the otherwise method on $stateProvider or how can I use it at all ?

Answer

Richard Keller picture Richard Keller · Jun 11, 2013

You can't use only $stateProvider.

You need to inject $urlRouterProvider and create a code similar to:

$urlRouterProvider.otherwise('/otherwise');

The /otherwise url must be defined on a state as usual:

 $stateProvider
    .state("otherwise", { url : '/otherwise'...})

See this link where ksperling explains