angular – 错误:由SyntaxError.ZoneAwareError模块’AppModule’导入的意外值’Http’

前端之家收集整理的这篇文章主要介绍了angular – 错误:由SyntaxError.ZoneAwareError模块’AppModule’导入的意外值’Http’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经多次检查过我的代码,并尝试在网络和stackoverflow上找到类似的问题,但我现在已经没有想法了,我根本看不出我的错误.你对我接下来要检查的内容有什么建议吗?

更新:当我调试我的配置类时,我可以看到,我的json-Configurations文件被读取,并且值在App-Initialize上正确存储到我的配置变量中(请参阅load() – plnkr上app.config.ts的功能) .
但是,如果我想从此配置变量值中获取值,例如第33行“werkzeug.service.ts”

let host:string = this.config.getConfig('host');

出现以下错误

TypeError: Cannot read property 'host' of null
    at AppConfig.getConfig (http://localhost:3000/app/app.config.js:31:27)
    at WerkzeugService.getSollIstWerkzeugBySchrankAndAnsicht (http://localhost:3000/app/werkzeug.service.js:47:32)
    at AppComponent.ngAfterViewInit (http://localhost:3000/app/app.component.js:37:30)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.detectChangesInternal (/AppModule/AppComponent/host.ngfactory.js:44:71)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:12206:18)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:12353:48)
    at ViewRef_.detectChanges (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:9375:24)
    at eval (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:8299:71)
    at Array.forEach (native)
    at ApplicationRef_.tick (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:8299:29)
    at ApplicationRef_._loadComponent (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:8274:18)
    at ApplicationRef_.bootstrap (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:8262:18)
    at eval (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:8091:93)
    at Array.forEach (native)
    at PlatformRef_._moduleDoBootstrap

这是我的项目设置:http://plnkr.co/edit/QsaOtnqFr0Ky9Qwz21SP?p=preview

@R_404_323@

HttpModule应该在导入但Http不应该.

@NgModule({
  imports:      [ BrowserModule,FormsModule,ReactiveFormsModule,HttpModule],declarations: [ AppComponent ],bootstrap:    [ AppComponent ],providers: [ AppConfig,{ provide: APP_INITIALIZER,useFactory: initConfig,deps: [AppConfig],multi: true }]  
})

示例http.get Plunker:http://plnkr.co/edit/60E2qb9gOjvkEAeR5CtE?p=info

猜你在找的Angularjs相关文章