You need to import the map
operator:
import 'rxjs/add/operator/map'
Or more generally:
import 'rxjs/Rx';
Notice: For versions of RxJS 6.x.x and above, you will have to use pipeable operators as shown in the code snippet below:
import { map } from 'rxjs/operators'; import { HttpClient } from '@angular/common/http'; // ... export class MyComponent { constructor(private http: HttpClient) { } getItems() { this.http.get('https://example.com/api/items').pipe(map(data => {})).subscribe(result => { console.log(result); }); } }
This is caused by the RxJS team removing support for using See the breaking changes in RxJS’ changelog for more info.
From the changelog:
operators: Pipeable operators must now be imported from rxjs like so:
import { map, filter, switchMap } from 'rxjs/operators';
. No deep imports.