10

Let say I go to /unknown-route?a=hello&b=world and $routeProvider doesnt recognize it and redirect to the otherwise route:

otherwise({
  redirectTo: '/default-route'
});

Is it possible to pass the given parameters to the redirected route.

Here it would be /default-route?a=hello&b=world

Jordane
  • 624
  • 1
  • 7
  • 23
  • Why are you using query parameters rather than the built in [$routeParams](https://docs.angularjs.org/api/ngRoute/service/$routeParams) of angular – Jared Reeves Sep 04 '14 at 13:34
  • Because its another app that could redirect to unknown route of this angular app – Jordane Sep 04 '14 at 13:43

1 Answers1

13

I found a working solution:

otherwise({
  redirectTo: function() {
    return '/default-route' + location.search;
  }
})
Jordane
  • 624
  • 1
  • 7
  • 23