AdrienTorris
AdrienTorris

Reputation: 9391

Migration from Angular2 beta1 to Angular2 beta15 - .map() error

I'm trying to migrate a project from Angular2 beta1 to Angular2 beta15 and I have some issues.

I have error message : 'map' property does not exists on 'Observable< Response >'

Example of code with this error :

import { Injectable } from 'angular2/core';
import { Http, Response, Headers } from 'angular2/http';
import { Observable } from 'rxjs/Observable';
import { HelperModule } from './helpers.module';
import { BlogPost } from './model';
import 'rxjs/add/operator/map';

/**
 * Service dealing with blog data
 */
@Injectable()
export class DataService {

    constructor(private http: Http) { }

    /**
     * Call API to list available blog posts
     */
    listBlogPosts() {
        return this.http.get(HelperModule.UrlBuilder.BuildPostListUrl()).map(res => (<Response>res).json());
    }

}

Code is available here : https://github.com/AdrienTorris/AspNet5Angular2Playground

EDIT : I'm using rxjs 5.0.0-beta6 and typescript 1.8.10, targetting es6

Upvotes: 0

Views: 78

Answers (2)

Jean-Philippe Leclerc
Jean-Philippe Leclerc

Reputation: 6795

Try using the latest version of Typescript (1.9) to compile your code. Module augmentation is bugged in some minor versions of TS 1.8. RXJS changed the way it defines its modules after 5.0.0-beta2.

You can try the nightly build using: npm install -g typescript@next

Upvotes: 1

Thierry Templier
Thierry Templier

Reputation: 202146

You need to import the map operator:

import 'rxjs/add/operator/map';

or all operators:

import 'rxjs/Rx';

See this question:

Upvotes: 0

Related Questions