Angular 2 http模块加载问题 [英] Angular 2 http module load issue

查看:74
本文介绍了Angular 2 http模块加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图开始将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆