how to redirect $routeProvider.otherwise() keeping the given query parameters
Asked Answered
H

1

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

Higgins answered 4/9, 2014 at 13:17 Comment(2)
Why are you using query parameters rather than the built in $routeParams of angularBesot
Because its another app that could redirect to unknown route of this angular appHiggins
H
13

I found a working solution:

otherwise({
  redirectTo: function() {
    return '/default-route' + location.search;
  }
})
Higgins answered 4/9, 2014 at 13:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.