0
votes

I'm working on a AngularJS project which uses dynamic states based on the future state mechanism of UI-Router-Extras (http://christopherthielen.github.io/ui-router-extras/#/future]). The future state mechanism works fine except the following:

If I use urlRouterProvider.otherwise() in the application config block the future state routing doesn't work anymore.

app.config(['$futureStateProvider', '$controllerProvider', '$stateProvider', '$urlRouterProvider',
    function($futureStateProvider, $controllerProvider, $stateProvider, $urlRouterProvider) {

  $urlRouterProvider.when("", "/start");
  $urlRouterProvider.when("/", "/start");
  $urlRouterProvider.otherwise("/error"); /* !!! --> no route to future state possible anymore */

  $stateProvider
  .state('start', {
     url: "/start",
     templateUrl: "start.html",
     controller: 'DemoMainCtrl'
   })
   .state('error', {
      url: "/error",
      templateUrl: "error.html"
   })
   ... some more states ...    

  /* here comes the code for the futute state setup as in the example: 
  http://christopherthielen.github.io/ui-router-extras/example/future/index.html#/
  whioch works fine as long as I'm not using $urlRouterProvider.otherwise("/error")*/

Any hints how to apply $urlRouterProvider.otherwise("/error"); the correct way or how to use any other automatic error routing mechanism (i.e. automatic route to an error view in case a state or URL is not available)?

1
Yeah, .otherwise doesn't work currently. github.com/christopherthielen/ui-router-extras/issues/39 - Chris T
Oh, can you suggest any other simple workaround for that scenario? - Tom
0.0.11 is going to add .otherwise support. It should be released soon. You can build ui-router-extras from master if you need it today. - Chris T
Thanks, this are good news! - Tom

1 Answers

1
votes

Circling back around, .otherwise() now works in 0.0.11+

https://github.com/christopherthielen/ui-router-extras/issues/39