angular2使SystemJS无法找到/angular2/http模块

angular2使SystemJS无法找到/angular2/http模块,angular,systemjs,Angular,Systemjs,我已经为Angular 2创建了一个服务: import {Injectable} from "angular2/core"; import {Http} from "angular2/http"; import {TaskModel} from "./tasks.model" @Injectable() export class TasksDataService { tasks:Array<any>; constructor(http:Http) { thi

我已经为Angular 2创建了一个服务:

import {Injectable} from "angular2/core";
import {Http} from "angular2/http";
import {TaskModel} from "./tasks.model"

@Injectable()
export class TasksDataService {

  tasks:Array<any>;

  constructor(http:Http) {

    this.tasks = [
      new TaskModel("Dishes"),
      new TaskModel("Cleaning the garage"),
      new TaskModel("Mow the grass")
    ];
  }

  getTasks():Array<any> {
    return this.tasks;
  }
}
从“angular2/core”导入{Injectable};
从“angular2/Http”导入{Http};
从“/tasks.model”导入{TaskModel}
@可注射()
导出类TasksDataService{
任务:阵列;
构造函数(http:http){
此参数为0.tasks=[
新的任务模型(“碟子”),
新任务模型(“清理车库”),
新任务模型(“割草”)
];
}
getTasks():数组{
返回此任务;
}
}
当我运行程序时,浏览器显示:

system.src.js:1049gethttp://localhost:3000/angular2/http.js 404(未找到)


我查阅了教程,它们以同样的方式包括angular2/http。有人看到哪里出了问题吗?

您需要检查主HTML文件中是否包含
http.dev.js
文件:

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>
希望它能帮助你,
蒂埃里

谢谢!但是这触发了另一个错误:angular.js:12477错误:没有Http的提供者!(任务->任务数据服务->Http)。我读过关于将其作为组件的提供者的内容,但这只是一个类。有什么线索吗?您需要添加HTTP_提供程序作为引导函数的第二个参数;-)我读过。但这是一个角度1混合应用程序。所以我的引导看起来像:adapter.bootstrap(document.body,[“app”]);和adapter.bootstrap(document.body,[“app”,HTTP_PROVIDERS])不起作用:)可能尝试将其放入数组:[“app”,“HTTP_PROVIDERS]”很好,但不起作用。然而,我将为这个问题提出一个新问题
import { HTTP_PROVIDERS } from 'angular2/http';

bootstrap(MyMainComponent, [ HTTP_PROVIDERS ]);