无法使用地图功能

时间:2018-05-25 10:20:19

标签: angular

    import { Injectable } from '@angular/core';
    import { Http,Headers } from '@angular/http';
     import { List } from '../models/List'
     import {Observable} from 'rxjs/Rx';
     import 'rxjs/add/operator/map';

     @Injectable()
export class ListService {

    constructor(private http: Http) { }

    private serverApi= 'http://localhost:3000';

    public getAllLists():Observable<List[]> {

        let URI = `${this.serverApi}/bucketlist/`;
        return this.http.get(URI)
            .map(res => res.json())

            .map(res => <List[]>res.lists);
    }

    public deleteList(listId : string) {
      let URI = `${this.serverApi}/bucketlist/${listId}`;
        let headers = new Headers;
        headers.append('Content-Type', 'application/json');
        return this.http.delete(URI, {headers})
        .map(res => res.json());
    }
}

我收到错误 物业地图不适用于类型Observable请任何人帮助

1 个答案:

答案 0 :(得分:1)

恕我直言,您使用的是旧语法。

执行以下操作:

import { map } from 'rxjs/operators';

然后:

this.myObservableFunctionCall().pipe(map(data => {}))