【发布时间】:2017-07-25 20:24:00
【问题描述】:
我想创建一个列表,但是当读取 Json 时出现此错误 我该如何解决?
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
/*
Generated class for the KpisProvider provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular DI.
*/
@Injectable()
export class KpisProvider {
private url: string = 'https://private-anon-3cb8931ec8-kpisapi1.apiary-mock.com/api/Projects';
constructor(private http: Http) {
console.log('Hello KpisProvider Provider');
}
getProjects(){
return this.http.get(this.url)
. .do((res: Response) => console.log(res))
.map((res: Response) => res.json());
}
}
错误是:
'(res: Response) => void' 类型的参数不能分配给类型参数 '部分观察者'。类型 '(res: Response) => void' 不可分配给类型 '完成观察者'。类型“(res:响应)=> void”中缺少属性“完整”。
L22: return this.http.get(this.url)
L23: .do((res : Response) => console.log(res))
L24: .map((res : Response) => res.json());
【问题讨论】:
标签: angularjs json mobile ionic-framework ionic2