I am trying to create a service that returns an Observable that my components can subscribe to. But I get the following error:
Property 'subscribe' does not exist on type 'Observable'.
I am currently running build alpha.44, and below you will find code that reproduces the problem.
import {Http} from 'angular2/http'; import {Observable} from 'angular2/core'; export class Backend { http: Http; constructor(http: Http) { this.http = http; this.getTeams().subscribe(); } public getTeams(): Observable { return this.http.get('/api/teams') .map(JSON.parse); } }
Changing the code to return "any" type seems to work, but it eliminates some of the benefits of using TypeScript. Is there a good way to use strict types for Observables in current Angular2 builds?
source share