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.

bug (router) routerState.queryParams.subscribe() often not triggered

See original GitHub issue

I’m submitting a … (check one with “x”)

[ x ] bug report

Current behavior sometimes (or most often) changes in the queryParams wont trigger an observable event.

Expected/desired behavior all changes to the queryParams will trigger an observable event

Reproduction of the problem on an ngOnInit method i subscribe to the following events:

this.router.events.subscribe(x => {
  console.log('router.events.subscribe:');
  console.log(x);
});

this.routeSubscription = this.router.routerState.queryParams.subscribe(params => {
  this.currentScope = params['scope'];
  this.currentOrder = params['order'];

  console.log('queryParams.subscribe: ${JSON.stringify(params)}');
});

and the view calls one of those functions:

{ const currentParas = this.router.routerState.snapshot.queryParams; currentParas['order'] = order; this.router.navigate(['/version/create'], { queryParams: currentParas }); }

image

the thing is: even if all navigate events will fired, and the browser shows the correct queryParams, the event wont triggered sometimes. it seems totaly random and i have no clue why.

What is the expected behavior?

each time i use router.navigate and append a queryParams, the routerState.queryParams observable will fire and event.

What is the motivation / use case for changing the behavior?

a simple dropdown where the user is able to select one of many filters and/or order for a list

Please tell us about your environment:

  • Angular version: 2.0.0-rc.4
  • Angular router: 3.0.0-beta.2
  • Browser: [Chrome Version 51.0.2704.106 m (64-bit) ]
  • Language: [all | TypeScript X.X | es5 ]

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
brandonrobertscommented, Jul 12, 2016

Thanks. I confirmed that this a bug. In the meantime, I’d recommend using Object.assign to store your snapshot params.

const currentParas = Object.assign({}, this.router.routerState.snapshot.queryParams);
0reactions
angular-automatic-lock-bot[bot]commented, Sep 11, 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

ionic4 Angular 7 query params subscribe is not triggering on ...
I'm trying to subscribe the query params. But it is not 'console' the changes when ever there is a change. It works in...
Read more >
How To Get Route Path Parameters In Non-Routed Angular ...
The options. Move non-routed component inside of the routed component (sometimes possible); Implement workaround based on router navigation events (for simple ...
Read more >
Router tutorial: tour of heroes - Angular
In this tutorial, you build upon a basic router configuration to explore features such as child routes, route parameters, lazy load NgModules, guard...
Read more >
Accessing Route Parameters with ActivatedRoute vs ...
Now we need to configure app-routing.module.ts. We make a route path that has a dynamic parameter that will be displayed in the HTML....
Read more >
angular/angular - Gitter
router.routerState.queryParams.subscribe(params => { console.log(params); }); ... (by disabled i mean the onclick event is not triggered).
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