title: TypeError: Cannot read property 'email' of undefined
body: <p>I have logs component that comes when i logged in:</p>
  
  <pre><code>import {Component, EventEmitter, Input, OnChanges,OnInit} from '@angular/core';
  import {Observable} from 'rxjs/Rx';
  import {Router} from '@angular/router';
  import { LogService } from '../services/logService.service';
  import {User,SharedService} from '../../SharedService'
  @Component({
      selector: 'dashboard',
      providers: [LogService],
      template: `
      &lt;div class="loader" *ngIf="loader"&gt;
          &lt;img src="../../images/loader-img.gif" alt="" /&gt;
      &lt;/div&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-10 col-md-offset-1"&gt;
                  &lt;div class="panel panel-default"&gt;
                      &lt;div class="panel-heading"&gt;Dashboard&lt;/div&gt;
  
                      &lt;div class="panel-body"&gt;
                          You are logged in! Welcome &lt;span&gt;{{ user.name }} &lt;/span&gt;
                          &lt;button type="submit" class="logout btn btn-primary"  (click)="logout()"&gt;Logout&lt;/button&gt;
                          &lt;hr/&gt;
                          &lt;table class="table"&gt;
                              &lt;thead&gt;
                                &lt;tr&gt;
                                  &lt;th&gt;Checkin time&lt;/th&gt;
                                  &lt;th&gt;Checkout time&lt;/th&gt;
                                  &lt;th&gt;Total time&lt;/th&gt;
                                &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody&gt;
                                &lt;tr *ngFor="let log of logs"&gt;
                                  &lt;td&gt;{{log.checkin}} &lt;/td&gt;
                                  &lt;td&gt;{{log.checkout}}&lt;/td&gt;
                                  &lt;td&gt;{{log.total_time}}&lt;/td&gt;
                                &lt;/tr&gt;
                              &lt;/tbody&gt;
                            &lt;/table&gt;
                      &lt;/div&gt;
  
                      &lt;button *ngIf="checking" type="submit" class="btn btn-primary btn-block" (click)="checkout(user.email)"&gt;Checkout&lt;/button&gt;
                      &lt;button *ngIf="!checking" type="submit" class="btn btn-warning btn-block" (click)="checkin(user.email)"&gt;Checkin&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
   `
  })
  export class LogsComponent implements OnInit, OnChanges {
   private checking = false;
   logs: any;
   log_id:any;
   user:User;
   loader = false;
  
   constructor(
       private logService: LogService,
       private router: Router,
       private ss:SharedService
       ){
          this.user=ss.getUserDetail();
       }
  
      checkin(values){
          this.loader = true;
      var current = this;
      // Variable to hold a reference of addComment/updateComment
      let logOperation:Observable&lt;any&gt;;
      logOperation = this.logService.CheckIn(values);
      logOperation.subscribe(
        res =&gt; {
            this.checking = true;
            this.log_id = res.log_id;
            this.loader = false;
         },
        err =&gt; { this.loader= false;}
  
     );
     }
    checkout(values){
      this.loader = true;
    var current = this;
    // Variable to hold a reference of addComment/updateComment
    let logOperation:Observable&lt;any&gt;;
    logOperation = this.logService.CheckOut(values,this.log_id);
    logOperation.subscribe(
      res =&gt; {
          this.checking = false;
          this.loader = false;
       },
      err =&gt; { this.loader = false; }
  
   );
     this.loadLogs();
   }
  
  logout(){
    this.loader = true;
    var current = this;
    this.logService.logout()
                    .subscribe(
                      res =&gt; {
                          if(res.isLoggedIn == false){
                            this.loader = false;
                            current.router.navigate(['/']);
                          }
                       },
                      err =&gt; { this.loader = false;}
                    );
  }
  
   loadLogs(){
          this.loader = true;
        // Get all comments
         this.logService.getLogs()
                           .subscribe(
                             res =&gt; {
                                this.logs =res.logs;
                                this.loader = false;
  
  
                              },
                             err =&gt; { this.loader = false; }
  
                          );
    }
   ngOnInit(){
            // Load comments
            this.loadLogs()
  
    }
  
  
    ngOnChanges(changes:any) {
        // Listen to the 'list'emitted event so as populate the model
        // with the event payload
  
      }
  
  }
  </code></pre>
  
  <p>In route i add hash.<code>useHash: true</code></p>
  
  <p>When i logged in i have this route :</p>
  
  <pre><code>http://localhost:3000/#/home
  </code></pre>
  
  <p>But when i refresh i get error from title. Any suggestion why is that? Do i need to send somehow data or ?</p>