title: refresh page in angular2 app
body: <p>I have two questions about refreshing page in angular2 app.
  The first one is done after the user clickes F5.
  I managed to find a solution to capture the user clicking F5 but I can't seem to capture this scenario but what I saw is that the previous history disappears because I see the document.location to the current page.</p>
  
  <p>The second question is capturing the refresh button in the browser on an angular2 app.
  I read a few people who also looked for a solution for that and saw that the solution was to use:
  <strong>onbeforeunload</strong> </p>
  
  <p>or</p>
  
  <p><strong>onUnload</strong>
  but this doesn't seem to work.
  Does angular has an out of the box handling for that?</p>
  
  <p>Here are my routes:</p>
  
  <pre><code>export const appRoutes: Routes = [
    { path: 'login', component: LoginComponent },
    { path: 'register', component: RegistrationComponent },
    {
      path: 'courses',
      component: CoursesListDetailsComponent,
      canActivate: [AuthGuard]
    },
    {
      path: 'course/:id/steps',
      component: CourseStepsListComponent,
      canActivate: [AuthGuard]
    },
    {
      path: 'course/:id/subCourses',
      component: SubCoursesListComponent,
      canActivate: [AuthGuard]
    },
    {
      path: 'step/:id',
      component: StepComponent,
      canActivate: [AuthGuard]
    },
    {
      path: 'course/:id/description',
      component: CourseDescriptionComponent,
      canActivate: [AuthGuard]
    },
    { path: '', component: LoginComponent },
    { path: '**', component: NotFoundComponent }
  ];
  </code></pre>