こんにちは、私は自分のコードに問題があります。角4 this.http.get(...)。mapは関数ではありません
this.http.get(...).map is not a function
しかし、私は追加します:このコードは、私はエラーを持っていると
import { Injectable } from '@angular/core';
import { Car } from "./models/car";
import { Observable } from "rxjs/Observable";
import { Http } from "@angular/http";
import 'rxjs'
@Injectable()
export class CarsService {
private apiUrl = "http://localhost:3000/api/cars";
constructor(private http : Http) { }
getCars() : Observable<Car[]> {
return this.http.get(this.apiUrl)
.map((res) => res.json())
}
}
import 'rxjs/add/operator/map'
はまだ問題が、エラーがあります:
Cannot read property 'map' of undefined
あなたが助けることができます私?ありがとう
何が角度のバージョン – Sajeetharan
角度CLIです:1.5.0 ノード:6.11.4 OS:Win32のx64の角度 :5.0.1 は、その5.0をOU。1私はバージョン4を使っていると思った。 –
角5には 'Http'が含まれなくなりました。これは 'HttpClient'に取って代わられました。 –