angular - 未捕获的类型错误 : StaticInjectorError(Platform: core)[t]: Cannot set property '_injector' of undefined

标签 angular build platform

源代码包含一个 rest API 调用以及全局变量引用,我也只使用了 bootstrap CSS 而没有保存 jquery,因为我没有使用 bootstrap.js 执行(ng build -prod)后我得到了 prod 构建文件,并且在我的本地服务器上一切正常。但是,当我在其他服务器上合并到 JSP 代码时,出现错误“Uncaught TypeError: StaticInjectorError(Platform: core)[t]: 无法设置未定义的属性“_injector””

最佳答案

这对我有用。

来自 app.module.ts:

import { HttpClientModule, HttpClient } from '@angular/common/http';
import { HttpModule} from '@angular/http';
...
imports:[HttpClientModule, HttpModule]

摘自 github 上的这些人。 https://github.com/angular/angular/issues/20096

似乎某些东西仍在使用 HttpModule,即使您很可能已切换到 HttpClient。

希望它对你有用。

关于angular - 未捕获的类型错误 : StaticInjectorError(Platform: core)[t]: Cannot set property '_injector' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48707044/

相关文章:

angular - 如何将 .Net Core Web Api 和 Angular 6 应用程序从 VS Code 发布到 Azure?

javascript - Angular2+,检查数组中是否存在具有类定义的值

javascript - Android 版本无法在设备上运行?

visual-studio - 错误 MSB6006 : "lc.exe" exited with code -1

operating-system - 内置脚本语言可用于所有主要操作系统?

video - 如何在不使用 RealServer (Helix) 和 Real Player 的情况下流式传输跨平台视频?

Angular 6 - 无法检索静态数据

html - PrimeNg 的 <pcalender> 中的日期验证逻辑

Windows 中不存在 OpenCV 库文件 (imgproc.hpp)

c++ - 在 Visual Studio 中编译时查找 C++ 平台目标