Using angular-ui-router, How can I use the otherwise method on $stateProvider or how can I use it at all ?
otherwise(rule: string | RawNg1RuleFunction): UrlRouterProvider. Defines the path or behavior to use when no url can be matched.
$stateProvider is used to define different states of one route. You can give the state a name, different controller, different view without having to use a direct href to a route. There are different methods that use the concept of $stateprovider in AngularJS.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With