angular - 我应该如何生成 app.module.ngfactory.ts 文件?

标签 angular

我正在尝试为 AOT 设置我的 angular2 应用程序。这似乎需要一个 app.module.ngfactory.ts 文件,而不是用于 JIT 的标准 app.module.ts 文件汇编。我的标准 JIT 应用程序有一个可用的 app.module.ts。我怎样才能将此文件的内容转换为 app.module.ngfactory.ts 的预期格式?

最佳答案

您需要使用ngc 编译它。基本步骤是:

1) 安装aot编译器

npm install @angular/compiler-cli

2) 添加配置到tsconfig.json:

  "angularCompilerOptions": {
   "genDir": "aot",
   "skipMetadataEmit" : true
 }

然后你可以运行ngc:

node_modules/.bin/ngc -p tsconfig.json

在输出的 aot 文件夹中,您将看到 app.module.ngfactory.ts 文件。

您可以阅读更多相关信息 here .

关于angular - 我应该如何生成 app.module.ngfactory.ts 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46122313/

相关文章:

Html:通过单击同一图像更改图像

node.js - 无法解析 'sha1'

angular - 以 Angular 使用来自其他组件的警报消息

javascript - Angular 8/Firebase : how do I set the displayName when creating user with email and password?

javascript - 如何回到 Ionic 4

angular - @HostListener 导致更改检测在我监听外部点击时触发太多次

javascript - Angular Material slider 24 小时格式化,步长为分钟

angular - 模拟 Angular 服务类属性或变量

angular - 使用 Auth0 spa 快速入门时出错

html - 如果来自 HTML 绑定(bind)的对象的 *ngFor Let 对象返回空数组,如何显示占位符