问题
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.
I added the following line in my main.ts
import { HTTP_PROVIDERS } from '@angular/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.
回答1:
you need this file in index.html to load those modules :-
<script src="node_modules/angular2/bundles/http.dev.js"></script>
or
<script src="node_modules/angular2/bundles/http.js"></script>
whichever is in your modules
EDIT :-
I think you need to link only the first file if you using beta in dev mode.both files are present though
来源:https://stackoverflow.com/questions/37088713/angular-2-http-module-load-issue