Angular 2 http 模块加载问题
Angular 2 http module load issue
我正在尝试开始将 Angular1 应用重写为 Angular2 应用。
我在 angular-cli 的帮助下开始了这个新项目,但我无法导入 http 服务。
我在 main.ts
中添加了以下行
import { HTTP_PROVIDERS } from '@angular/http';
而这个在我的服务中需要使用 http
import { Http, Response } from '@angular/http';
对于这两行我有以下错误:
Cannot find module '@angular/http'
你知道我会错过什么吗?
谢谢。
你需要 index.html 中的这个文件来加载这些模块:-
<script src="node_modules/angular2/bundles/http.dev.js"></script>
或
<script src="node_modules/angular2/bundles/http.js"></script>
以你模块中的那个为准
编辑:-
我认为如果你在开发中使用 beta mode.both 文件,你只需要 link 第一个文件
我正在尝试开始将 Angular1 应用重写为 Angular2 应用。 我在 angular-cli 的帮助下开始了这个新项目,但我无法导入 http 服务。
我在 main.ts
中添加了以下行import { HTTP_PROVIDERS } from '@angular/http';
而这个在我的服务中需要使用 http
import { Http, Response } from '@angular/http';
对于这两行我有以下错误:
Cannot find module '@angular/http'
你知道我会错过什么吗? 谢谢。
你需要 index.html 中的这个文件来加载这些模块:-
<script src="node_modules/angular2/bundles/http.dev.js"></script>
或
<script src="node_modules/angular2/bundles/http.js"></script>
以你模块中的那个为准
编辑:-
我认为如果你在开发中使用 beta mode.both 文件,你只需要 link 第一个文件