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.

I’m submitting a…

[X] Feature request

Current behavior

Seems there is no hook for page reload or refresh. A hook like onPageRefresh() will be helpful for page refreshes.

Expected behavior

When a refresh page is initiated by user in the browser,the parent app component is reloaded. When the parent component is reloaded,there could be manual redirections on the parent component which loses the current page that the user was on. For instance,let’s say in my home component,I check to see the presence of an unexpired jwt key and redirect a user to a “home” route. Now when a user is on a “purchase” route and refreshes the page,the app home component is recreated and it redirects to the home route upon seeing the presence of an unexpired jwt key instead of reloading the “purchase” route or component.

Minimal reproduction of the problem with instructions


import {BrowserModule} from '@angular/platform-browser';
import {Component, NgModule} from '@angular/core';


import {Router, RouterModule} from '@angular/router';


@Component({
  selector: 'app-root',
  template: `
    <router-outlet></router-outlet>
  `,
  styleUrls: ['./app.component.css']
})
export class MainComponent {
  constructor(private router: Router) {
    this.router.navigate([('home')]);
  }
}

@Component({
  selector: 'app-root-home',
  template: `
    <div>home works</div>
    Go to random
  `
})
export class HomeComponent {

}

@Component({
  selector: 'app-root-random',
  template: `
    <div>random route works</div>
  `
})
export class RandomComponent {
  // when random component is loaded and we refresh the page,
  // it riderects back to home component(ie '/home' route) instead of the same '/random' route.
}


@NgModule({
  declarations: [
    MainComponent,
    HomeComponent,
    RandomComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot([
      {
        path: '',
        component: MainComponent,
        children: [
          {
            path: 'home',
            component: HomeComponent
          },
          {
            path: 'random',
            component: RandomComponent
          }
        ]
      }
    ])
  ],
  providers: [],
  bootstrap: [MainComponent]
})
export class AppModule {
}

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

refresh an angular page and still stay on the same page after refresh

Environment


Angular version: 5.2.0


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

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
trotylcommented, Feb 12, 2018

How would you like to implement that? By comparing current time and last close time? By session expiry cookie? How do you make sure there is no false positive?

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 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

Enhancement Definition & Meaning - Dictionary.com
the state or quality of being elevated, heightened, or increased, as in quality, degree, intensity, or value: The latest update brings many performance ......
Read more >
Meaning of enhancement in English - Cambridge Dictionary
a change, or a process of change, that improves something or increases its value: We have made many enhancements to the software that...
Read more >
Enhancement - Definition, Meaning & Synonyms
The noun enhancement comes from the verb enhance, meaning "to increase or improve," and it can describe anything that's an improvement to the...
Read more >
4 Synonyms & Antonyms for ENHANCEMENT - Thesaurus.com
Find 4 ways to say ENHANCEMENT, along with antonyms, related words, and example sentences at Thesaurus.com, the world's most trusted free thesaurus.
Read more >
Enhance Definition & Meaning - Merriam-Webster
The meaning of ENHANCE is heighten, increase; especially : to increase or improve in value, quality, desirability, or attractiveness.
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