19
带有TypeScript错误http.get(…).map的角度HTTP GET不是[null]中的函数
我在Angular中遇到HTTP问题。 我只想要GET一个JSON列表并在视图中显示它。 服务等级 import {Injectable} from "angular2/core"; import {Hall} from "./hall"; import {Http} from "angular2/http"; @Injectable() export class HallService { public http:Http; public static PATH:string = 'app/backend/' constructor(http:Http) { this.http=http; } getHalls() { return this.http.get(HallService.PATH + 'hall.json').map((res:Response) => res.json()); } } 在中,HallListComponent我getHalls从服务中调用方法: export class HallListComponent implements OnInit { public halls:Hall[]; …