[英]Exception in Angular2 app
I am getting this exception in console: 我在控制台中收到此异常:
Error in ./AppComponent class AppComponent - inline template:0:32 caused by: No provider for Http!
./AppComponent类AppComponent中的错误-内联模板:0:32,其原因是:没有Http的提供程序!
Why should I provide HTTP providers in app component? 为什么要在应用程序组件中提供HTTP提供程序?
Make sure you have the following code in your App Module or whichever module declares AppComponent
: 确保您的App模块中包含以下代码,或者任何一个声明
AppComponent
模块:
import { HttpModule } from '@angular/http';
@NgModule({
// ...
imports: [
// ...
HttpModule
]
// ...
})
export class AppModule {}
For an example, see this page from Angular's tutorial. 有关示例,请参见Angular教程中的此页面 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.