错误'Observable <response>类型上不存在属性映射

时间:2016-10-25 09:46:29

标签: angular visual-studio-2015 rxjs

以下是我的service.ts。我添加了map并单独捕获。 observable<response>

不存在财产
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable'; // for handling service     response - like promise

import { DashboardModel } from '../model/dashboard.model' 



import 'rxjs/add/operator/map';   
import 'rxjs/add/operator/catch';// Import RxJs required methods

@Injectable()

export class AppService {
constructor(private http: Http) { }
// private instance variable to hold base url
private baseUrl = 'https://www.google.co.in';


// Fetch all existing comments
getDetails(): Observable<DashboardModel[]> {

    // ...using get request
    return this.http.get(this.baseUrl)
        // ...and calling .json() on the response to return data
        .map((res: Response) => res.json())
        //...errors if any
        .catch((error: any) => Observable.throw(error.json().error || 'Server error'));
}
} 

编辑:我已经看到了解决方案,在哪里添加map,catch等要单独导入。即便如此,我也会遇到同样的错误。

0 个答案:

没有答案