试图集成角4+@ngx-翻译。所有东西都在使用npm start正常执行和工作。当我尝试npm test运行Karma测试用例时,会出现问题。所有这些都是在添加了@ngx-翻译功能之后开始的。控制台出现以下错误:
20 09 2017 14:24:30.334:INFO [Chrome 60.0.3112 (Windows 7 0.0.0)]: Connected on socket n1uvSjMzMfCGU26zAAAA with id 7587189
Chrome 60.0.3112 (Windows 7 0.0.0) ERROR
Uncaught TypeError: Cannot read property 'Injectable' of undefined
at node_modules/@ngx-translate/core/bundles/core.umd.js:817浏览器控制台上的:
Uncaught TypeError: Cannot read property 'Injectable' of undefined
at Object.<anonymous> (core.umd.js:817)
at __webpack_require__ (core.umd.js:30)
at Object.module.exports (core.umd.js:1421)
at __webpack_require__ (core.umd.js:30)
at module.exports (core.umd.js:76)
at core.umd.js:79
at webpackUniversalModuleDefinition (core.umd.js:9)
at core.umd.js:10
ng-bootstrap.js:9 Uncaught TypeError: Cannot read property 'core' of undefined
at webpackUniversalModuleDefinition (ng-bootstrap.js:9)
at ng-bootstrap.js:10浏览器上的:
OtherComponent when inside a test host should process Instance name
TypeError: Cannot read property 'bpmWrapWorkItemList' of undefined
TypeError: Cannot read property 'bpmWrapWorkItemList' of undefined救命啊!我对角4还不熟悉。
发布于 2017-10-03 09:06:41
请将beforeEach块用于翻译服务的更新语言
beforeEach(inject([TranslateService], (service: TranslateService) => {
service.use('de');
}));发布于 2017-11-27 21:25:14
我有一个类似的问题,并且能够通过删除.angular-cli.json中的两个脚本定义来解决这个问题。
我代替了
"scripts": [
"../node_modules/@ngx-translate/core/bundles/core.umd.js",
"../node_modules/@ngx-translate/http-loader/bundles/http-loader.umd.js"
],使用
"scripts": [],虽然这解决了问题,而且翻译服务仍然有效,但我不知道为什么首先需要这些脚本,以及是否可以删除它们。
https://stackoverflow.com/questions/46319990
复制相似问题