未捕获的TypeError:StaticInjectorError(Platform:core)[t]:无法设置未定义

时间:2018-02-09 13:31:33

标签: angular build platform

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

2 个答案:

答案 0 :(得分:3)

这对我有用。

来自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

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

希望它对您有用。

答案 1 :(得分:1)

我有同样的问题,这个问题是由于角度库js文件与jsp或html脚本的冲突,你可能已经合并了你的角度代码....请检查是否有一些原型方法将覆盖角度核心文件......