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.

Resolver not called when upstream params change

See original GitHub issue

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

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Resolvers are not called when an upstream route param changes. This is wrong as the parent route param may obviously have significance. e.g company/1/employee/2 company/2/employee/2 Employee 2 is not the same employee even though the param is 2 in both cases.

Expected behavior

The resolver would be called and could fetch the proper data which would then be made available to component as route data

Minimal reproduction of the problem with instructions

See https://github.com/slubowsky/resolve-issue Run the app (ng serve). Click on the links to navigate. Going to / from “1 and 1” to / from either of the others results in resolver being called and message being logged to the console. Going between “1 and 2” and “2 and 2” does not. Resolver is never called. Component would not be updated.

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

Its currently broken. Cant keep component current with route using a resolver and route.data.

Thinking about this a bit more, can it be that the design is such that resolvers are only meant to be called before a component is shown for the first time (to prevent “blank” component), but once a component is showing, the resolver and route.data are never meant to be called and updated even if the route changes? If this is the case, then I need to handle the exact same thing, getting route params and fetching the appropriate data, in two places. First get the params and fetch the data in the resolver and subscribe to ActivatedRoute.data for the first update, and then do the same thing again whenever the route changes.

Bigger problem is that I have no way of knowing the route changed (ActivatedRoute.params is not updated either). I suppose we could subscribe to router events and get snapshot or something on NavigationEnd but things are getting very messy, multiple paths instead of one, cut and pasted code, etc… I hope this is just a bug…

Plus it does seem to be called when this route segments parameters change so things are really getting strange. Lots of different scenarios that all should be exactly the same but instead are all different…

Please tell us about your environment:

Windows 10, Visual Studio Code, Angular-cli 1.0.0-beta.20-4

  • Angular version: 2.0.X

2.2.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Only tried Chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript 2.0.10

  • Node (for AoT issues): node --version =

Issue Analytics

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

github_iconTop GitHub Comments

8reactions
vicbcommented, Dec 1, 2016

The current behavior is by design.

Both strategies are reasonable in some use cases - it just happen that we have implemented the one that does not make sense in your use case.

What you can do is to inject the activatedRoute and load the Employee in your component.

6reactions
klinkicommented, Dec 2, 2016

@vicb I’m sorry but I’m really tired of hearing “The current behavior is by design” and similar sentences. Could you please provide us The Design, so we would know how are we supposed to use router?

Currently there are so many pitfalls and I think there are quite a lot of people experiencing them. And surprisingly, most of them are by design.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve not called for child routes in angular 2 - Stack Overflow
It seems there is a bug in Angular Router. The children's resolvers are not triggered in this case when parent route param is...
Read more >
Resolver does not re-resolve upstream servers after initial cache
Using nginx 1.2.3-stable on Ubuntu 12.04 I have the following config: http { resolver 172.16.0.23 valid=300s; resolver_timeout 10s; upstream ...
Read more >
intercept - Cypress Documentation
The routeHandler function is called whenever a request is matched, with the first argument being the request object. From inside the callback, you...
Read more >
HTTP Load Balancing | NGINX Plus
Load balance HTTP traffic across web or application server groups, with several algorithms and advanced features like slow-start and session persistence.
Read more >
git-rev-parse Documentation - Git
Do not output flags and parameters not meant for git rev-list command. ... HEAD names the commit on which you based the changes...
Read more >

github_iconTop Related Medium Post

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