首页 > 解决方案 > Angular.During ng build --prod get error : Uncaught (in promise): Cannot read property 'call' of undefined

问题描述

在我的角度应用程序中使用外部角度元素(webcomponents)时出现以下错误。

未捕获(承诺):TypeError:无法读取未定义的属性“调用” TypeError:无法读取未定义的属性“调用”

它仅在以生产模式构建(ng build --prod)、优化设置为 true 且延迟加载时发生。

package.json 依赖:

"devDependencies": {
    "@angular-devkit/build-angular": "^0.7.0-rc.0",
    "@angular/cli": "^6.2.3",
    "@angular/compiler-cli": "^6.1.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "pre-commit": "^1.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }

以下是复制步骤。

应用程序源(GIT 存储库):

https://github.com/gowthamr123/repro-app

运行 npm install do ng serve 并转到以下 url 后:

http://localhost:4200/selfcare/tariff-change

它会正常工作。

现在在生产模式下运行 ng serve --prod

发生错误:

未捕获(承诺):TypeError:无法读取未定义的属性“调用” TypeError:无法读取未定义的属性“调用”

任何帮助将非常感激。

标签: angularangular6angular-elements

解决方案


推荐阅读