Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 456
Jordane Avatar asked Sep 04 '14 13:09

Jordane


1 Answers

I found a working solution:

otherwise({
  redirectTo: function() {
    return '/default-route' + location.search;
  }
})
like image 155
Jordane Avatar answered Sep 21 '22 07:09

Jordane