angular – 错误:由SyntaxError.ZoneAwareError模块’AppModule
发布时间:2020-12-17 18:00:02 所属栏目:安全 来源:网络整理
导读:我已经多次检查过我的代码,并尝试在网络和stackoverflow上找到类似的问题,但我现在已经没有想法了,我根本看不出我的错误.你对我接下来要检查的内容有什么建议吗? 更新:当我调试我的配置类时,我可以看到,我的json-Configurations文件被读取,并且值在App-Ini
我已经多次检查过我的代码,并尝试在网络和stackoverflow上找到类似的问题,但我现在已经没有想法了,我根本看不出我的错误.你对我接下来要检查的内容有什么建议吗?
更新:当我调试我的配置类时,我可以看到,我的json-Configurations文件被读取,并且值在App-Initialize上正确存储到我的配置变量中(请参阅load() – plnkr上app.config.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 解决方法
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |