onSameUrlNavigation doesn't re-load routed components
See original GitHub issueI’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:
- Created 6 years ago
- Reactions:21
- Comments:83 (27 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can’t we just have a “reload()” method? This is like buying a dairy farm to get an ice cream cone.
@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. 👌