Angular 2 http模块加载问题 [英] Angular 2 http module load issue
问题描述
我正试图开始将Angular1应用重写为Angular 2应用. 我在angular-cli的帮助下开始了这个新项目,但我阻止导入http服务.
I'm trying to start to rewrite an Angular1 app into Angular 2 app. I start this new project with th help of angular-cli but I'm block to import http service.
我在main.ts中添加了以下行
I added the following line in my main.ts
import { HTTP_PROVIDERS } from '@angular/http';
这是我服务中需要使用http
And this one in my service that need to use http
import { Http, Response } from '@angular/http';
对于这两行,我有以下错误:
And for there two lines I have the following error:
Cannot find module '@angular/http'
您对我想念的东西有一些了解吗? 谢谢.
Have you some Idea about what can i miss ? Thank you.
推荐答案
您需要index.html中的此文件来加载这些模块:-
you need this file in index.html to load those modules :-
<script src="node_modules/angular2/bundles/http.dev.js"></script>
或
<script src="node_modules/angular2/bundles/http.js"></script>
您模块中的任何一个
-
如果您在开发人员模式下使用Beta,我认为您只需链接第一个文件即可.尽管这两个文件都存在
I think you need to link only the first file if you using beta in dev mode.both files are present though
这篇关于Angular 2 http模块加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!