class variable is undefined after subscribing observable in lifecycle hook
<p>I try to set a variable (json object) in my component class. ngOnInit subscribing an observable service and set the component variable. 
When I try to access this variable with dot notation in components template, I get this error:</p>

<blockquote>
  <p>Cannot read property 'count_runs' of undefined</p>
</blockquote>

<p>The observable has a type annotation (avgTime Interface).</p>

<p>avg-time.ts</p>

<pre><code>export interface AvgTime {
  avg_runtime_millis: number;
  count_runs: number;
}
</code></pre>

<p>stats.service.ts</p>

<pre><code>import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { AvgTime } from './avg-time';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class StatsService {
  constructor(private _http: Http) { }

  private _avgTimeUrl = 'http://localhost:3002/api/reservation/avgTime';

  getAvgTime() : Observable&lt;AvgTime&gt; {
    return this._http.get(this._avgTimeUrl)
               .map(res =&gt; res.json());
  }
}
</code></pre>

<p>avg-time.component.ts</p>

<pre><code>import {Component, OnInit} from '@angular/core';
import { AvgTime } from './avg-time';
import { StatsService } from './stats.service';

@Component({
  selector: 'avg-time',
  template: `
    &lt;h1&gt;AvgTimeComponent&lt;/h1&gt;
    {{avgTime.count_runs}}
  `,
  providers: [StatsService]
})
export class AvgTimeComponent implements OnInit {
  avgTime: AvgTime;

  constructor(private _statsService: StatsService) { }

  ngOnInit() {
    this._statsService.getAvgTime()
        .subscribe(avgTime =&gt; this.avgTime = avgTime);
  }
}
</code></pre>

<p>It is also not working when I fake the service response in ngOnInit like:</p>

<p>avg-time.component.ts</p>

<pre><code>  ngOnInit() {
    this._statsService.getAvgTime()
        .subscribe(avgTime =&gt; {
          this.avgTime = {
            avg_runtime_millis: 150,
            count_runs: 20
          };
        });
  }
</code></pre>

<p>The return of my stats.service.ts from backend is:</p>

<pre><code>[{"AVG_RUNTIME_MILLIS":55,"COUNT_RUNS":5400}]
</code></pre>