Using angular-ui-router, How can I use the otherwise method on $stateProvider or how can I use it at all ?
You can with $stateProvider
using the catch all syntax ("*path"
). You just need to add a state config at the bottom of your list like the following one:
$stateProvider.state("otherwise", {
url: "*path",
templateUrl: "views/error-not-found.html"
});
All the options are explained in https://github.com/angular-ui/ui-router/wiki/URL-Routing#regex-parameters.
The nice thing of this option, as opposed to $urlRouterProvider.otherwise(...)
, is that you 're not forced to a location change.