title: Angular 2 - Route guard not working on browser refresh
body: <p>Having these routes defined in app.module.ts</p>
  
  <pre><code>...
  { path: 'mypath', component: MyComponent, canActivate: [RouteGuard] }, 
  { path: '', redirectTo: '/home', pathMatch: 'full' },
  { path: '**', redirectTo: '/home'}
  </code></pre>
  
  <p>and this guard service</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { CanActivate } from '@angular/router';
  import { AngularFire } from 'angularfire2';
  import { AngularFireAuth } from 'angularfire2';
  
  @Injectable()
  
  export class RouteGuard implements CanActivate {
  
    private loggedIn: boolean;
  
    constructor ( private af: AngularFire, private auth: AngularFireAuth ) {}
  
    canActivate(): boolean {
  
      this.auth.subscribe(auth =&gt; {
        if  (auth)  { this.loggedIn = true; }
        else        { this.loggedIn = false; }
  //          this.router.navigate(['/login']); for future implememtation
         });
  
      return this.loggedIn;
    }
  }
  </code></pre>
  
  <blockquote>
    <p>refreshing the browser from url <code>//mysite/mypath</code> the app goes to
    <code>//mysite</code> instead of <code>//mysite/mypath</code> (and also skips the default
    route).</p>
  </blockquote>
  
  <p>Without any guard activated on mypath route (ie: <code>{ path: 'mypath', component: MyComponent }</code>everything works perfectly.</p>
  
  <p>Does anybody knows if this is an Angular bug ?
  How could I avoid this behaviour ?</p>
  
  <p>My dev env is:</p>
  
  <pre><code>@angular/cli: 1.0.0-rc.1
  node: 7.5.0
  os: linux x64
  @angular/cli: 1.0.0-rc.1
  @angular/common: 2.4.9
  @angular/compiler: 2.4.9
  @angular/compiler-cli: 2.4.9
  @angular/core: 2.4.9
  @angular/flex-layout: 2.0.0-rc.1
  @angular/forms: 2.4.9
  @angular/http: 2.4.9
  @angular/material: 2.0.0-beta.2
  @angular/platform-browser: 2.4.9
  @angular/platform-browser-dynamic: 2.4.9
  @angular/router: 3.4.9
  </code></pre>
  
  <p>Thanks for helping me.</p>
  
  <p>PS: I have tried to find an answer both on Stack Overflow or on Github issues without finding an answer. I saw a similar question <a href="https://stackoverflow.com/questions/38751327/angular-2-routing-not-working-on-page-refresh-with-apache">Angular 2 routing not working on page refresh with Apache</a>, but this is not my case.</p>