1
我很新的Angular2/4和我有一些問題,試圖按照本教程涉及PrimeNG:爲什麼我在Angular應用程序中獲取這個錯誤?住宅「toPromise」不上類型存在「可觀察<Response>」
https://www.primefaces.org/primeng/#/schedule
我創建了EventService類到我prohject文件,以這樣的方式
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
@Injectable()
export class EventService {
constructor(private http: Http) {}
getEvents() {
return this.http.get('showcase/resources/data/scheduleevents.json')
.toPromise()
.then(res => <any[]> res.json().data)
.then(data => { return data; });
}
}
的PROBL EM是WebStorm給我一個錯誤的toPromise()方法,它說:
Error:(11, 8) TS2339:Property 'toPromise' does not exist on type 'Observable<Response>'.
爲什麼?這是什麼意思?問題是什麼?我怎樣才能解決它?
的[屬性「toPromise」上不存在類型「可觀察」]可能的複製(https://stackoverflow.com/questions/38090989/ property-topromise-does-exist-on-type-observableresponse) –
Alex
你寫這個問題的時間量,你可能剛剛google了錯誤信息並找到了答案? ;) – Alex