question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Router: there is no way to redirectTo passing along query string params to the target route.

See original GitHub issue

I’m submitting a …

[ ] bug report
[X] feature request
[ ] support request

Current behavior There is no way to configure a route redirectTo another route passing query string params to the target route.

Expected/desired behavior Perhaps something like this?

  {
    path: '**',
    redirectTo: '/list?param=true',
    terminal: true
  }

This will currently fail with EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: 'list?param=true'

Reproduction of the problem This plunker illustrates the issue, see app.app-routes.rs

http://plnkr.co/edit/KHEWJhMBlZviHrZVqbDS?p=preview

devtools will log the error. If we just remove ?param=true from the redirectTo, it all works well.

What is the expected behavior? I would expect the catch all route to redirect to /list passing along the param=true parameter, as specified in the redirect. If the redirectTo cannot accept URLs, then perhaps we could have another parameter to the route config to allow passing in query params?

Please tell us about your environment:

  • Angular version: 2.0.0-rc.4
  • Browser: all
  • Language: TypeScript 1.8.10

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
brumasriberacommented, Jul 5, 2017

It only works with absolute routes that contain ‘/’ on the redirect. Could it be possible to implement it so that we could use something like redirectTo: 'list?param=true'?

0reactions
angular-automatic-lock-bot[bot]commented, Sep 14, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular2 router keep query string - Stack Overflow
If you look at any ActivatedRoute, you can find the "params" route using: var paramsRoute = this. activatedRoute.
Read more >
How To Use Query Parameters with Angular Router
Query parameters in Angular allow for passing optional parameters across any route in the application. Query parameters are different from ...
Read more >
InDepth guide to passing parameters via routing - Angular ...
In this guide we will go through the most popular features available in Angular - route required params and query params. In the...
Read more >
Common Routing Tasks - Angular
This topic describes how to implement many of the common tasks associated with adding the Angular router to your application.
Read more >
HTTP route components (proto) - Envoy Proxy
The top level element in the routing configuration is a virtual host. ... If query parameters are used to pass request message fields...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found