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.

Can't access queryParams and fragments from canLoad

See original GitHub issue

πŸš€ feature request

Relevant Package

This feature request is for @angular/router

Description

#12411 and #17359 are still not solved, even though now the `canLoad` function possesses a `UrlSegment[]` argument. This argument enable us to access matrix parameters, but the query parameters and fragments of the destination url are still out of reach from inside of the `canLoad`function

Describe the solution you’d like

Instead of a `UrlSegment[]` argument, what we need is a `UrlTree`

Describe alternatives you’ve considered

The only solutions available right now are still the same ones that have been given previously, and they are not satisfactory : either access the exact url from the `window` object (but there are lots of situation when the browser and router state are not in sync, like when using `skipLocationChange`) or give up on `canLoad` altogether and only use `canActivate` (but lose the benefit of lazyloading).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
stevethemacguycommented, Jun 5, 2020

One year later, and there’s still no way to access query parameters in CanLoad, so it’s not possible to redirect the user to their intended destination url. 😒

0reactions
angular-automatic-lock-bot[bot]commented, Mar 15, 2021

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

Angular 2: how do I get route parameters from CanLoad ...
The problem that I'm having is that I can't get any route parameters if the state is being initialized from a different state...
Read more >
Angular Basics: Getting Data From Fragments and Query ...
In this post, we are going to look into how you can retrieve data from URL query parameters in Angular inside the component...
Read more >
Router tutorial: tour of heroes - Angular
However, you can use query parameters to get optional parameters available to all routes. Fragments refer to certain elements on the page identified...
Read more >
Reloading Components when change in Route Params
Now let's say you want to open the details of another user, if you try and click the other one, it won't work....
Read more >
Testing Angular route guards with the RouterTestingModule
When AuthGuard guards a CanLoad hook, access to route is rejected and its feature ... objectContaining({ queryParams: expectedQueryParamsΒ ...
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