Skip to content

Add queryParams support for routeInterceptor #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
prusama opened this issue May 5, 2025 · 2 comments
Open

Add queryParams support for routeInterceptor #215

prusama opened this issue May 5, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@prusama
Copy link

prusama commented May 5, 2025

🧩 Add queryParams support for routeInterceptor

Description

routeInterceptor can return only string and this is having a lot of disadvantages. You cannot pass any queryParams. If you try to modify the string and append the queryparams to your route, you are going to get:
ERROR RuntimeError: NG04002: Cannot match any routes. URL Segment: 'your-route%3FmyQueryParam%3Dtrue'

The query params are getting encoded by Angular router and you are going to get error, because the route is not being recognized.

Describe the solution you'd like

I think that best scenario could be that routeInterceptor would return nothing, but it could be some kind of callback and anybody could wrote its own logic which should be executed when user clicks the link.

routeInterceptor: () => {
    this.router.navigate(['my-route'], {
        queryParams: {
            myQueryParam: true
        }
    })
}

Describe alternatives you've considered

I tried to convert queryParams into string and append it to the returned string, but it resulted into that error I described above. So there is no workaround. There is no workaround.

@prusama prusama added the enhancement New feature or request label May 5, 2025
Copy link

github-actions bot commented May 5, 2025

👋 Hey @prusama


Thanks for flagging your first issue! We're on it! Please provide all the details you can


Got a fix? Send a PR! 🚀 Check out our local dev guide

If you like this project, please ⭐star⭐ our repo.

@prusama
Copy link
Author

prusama commented May 6, 2025

I found temporary solution:

this.breadcrumbs.set('test', {
      label: this.translationService.instant('title'),
      routeInterceptor: () => '/action-plans',
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-ignore
      queryParams: queryParams
});

queryParams attribute is not exported, but it works, so it needs to be marked with // @ts-ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant