2

尝试集成Angular 4 + @ngx-translate。一切都在执行并与 npm start. 当我尝试npm test运行 Karma 测试用例时出现问题。所有这些都是在添加 @ngx-translate 功能之后开始的。 控制台出现以下错误:

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

请帮忙 !!!我是Angular 4的新手..

4

2 回答 2

1

请在每个块之前放置以更新翻译服务的语言

beforeEach(inject([TranslateService], (service: TranslateService) => {
    service.use('de');
  }));
于 2017-10-03T09:06:41.243 回答
0

我有一个类似的问题,并且能够通过删除.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": [],

虽然这解决了问题,并且翻译服务仍然有效,但我不知道为什么首先需要这些脚本,以及是否可以删除它们。

于 2017-11-27T21:25:14.713 回答