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.

onSameUrlNavigation doesn't re-load routed components

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

I’m trying to use the new onSameUrlNavigation flag in 5.1.1, and while it does repeat the RouterEvent cycle, it doesn’t trigger any lifecycle events in the routed components

Expected behavior

ideally if it’s going to trigger a reload, it should re-initialize any routed components.

Minimal reproduction of the problem with instructions

imports: [RouterModule.forRoot([ { path: “”, component: HomeComponent, pathMatch: “full” }, { path: “login”, component: LoginComponent }, ], { onSameUrlNavigation: “reload” })]

This configuration will not trigger lifecycle events in LoginComponent if there’s a link to LoginComponent somewhere on the page

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

This flag was added to support refresh, but developers would still have to listen to the router event cycle to be able to refresh any components this way

Environment


Angular version: 5.1.1


Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ x] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ x] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:21
  • Comments:83 (27 by maintainers)

github_iconTop GitHub Comments

46reactions
chadbrcommented, Mar 7, 2018

Can’t we just have a “reload()” method? This is like buying a dairy farm to get an ice cream cone.

31reactions
mlc-mlapiscommented, Dec 20, 2017

@TylerDev6 … from where did you take that onSameUrlNavigation should introduce triggering of life-cycle hooks on components? As I know from source code it was introduced to re-invoke only guards & resolvers.

Sorry … your issue is the feature issue. 👌

Read more comments on GitHub >

github_iconTop Results From Across the Web

onsameurlnavigation 'reload' not working in angular
Please be noted that onSameUrlNavigation only executes guards and resolvers but does not reinitialize components.
Read more >
Angular: Refetch data on same URL navigation - Medium
The onSameUrlNavigation property accepts either 'reload' or ... Let's say our routed component defines its router outlet with routed child ...
Read more >
How to reload/refresh the data when navigate to same route in ...
I have an issue with the route. Routing File const routes = [ { path: '', // base route is `setting` component: SettingViewComponent,...
Read more >
onSameUrlNavigation reload for specific route-angular.js
Only onSameUrlNavigation: reload alone doesn't work in the component, using it after shouldReuseRoute works: constructor(private router:Router){} ...
Read more >
Router tutorial: tour of heroes - Angular
That doesn't match any of the hard-coded routes which means the router falls through to ... Next, update the app.module.ts file by removing...
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