Angular 2 Aot:Zoneware (SystemJS) XHR 错误
Angular 2 Aot : Zoneware (SystemJS) XHR error
我正在研究 Angular 提前编译 (AoT),我在其中生成 build.js 文件并在加载时遇到以下问题
(SystemJS) XHR error (404 Not Found) loading http://localhost:58082/aot/app/app.module.ngfactory
index.html
中包含以下文件
<script src="shim.min.js"></script>
<script src="zone.min.js"></script>
出现这个问题的三种可能
1) 我们将此脚本包含在 index.html 页
<script>window.module = 'aot';</script>
所以我们必须在每个组件中包含模块字段以及选择器和模板
@Component({
moduleId: module.id,
selector: 'myapp',
templateUrl: '../../master/html/test.html'
})
2)这个脚本应该在html页的底部
<script src="dist/build.js"></script>
3)最后但重要的是,提前编译没有延迟加载
这解决了我的问题,使用 AOT 的应用程序 运行 但内部遇到了一些问题,例如堆栈的 Zoneware 错误 undefined.Resolving。
我正在研究 Angular 提前编译 (AoT),我在其中生成 build.js 文件并在加载时遇到以下问题
(SystemJS) XHR error (404 Not Found) loading http://localhost:58082/aot/app/app.module.ngfactory
index.html
中包含以下文件<script src="shim.min.js"></script>
<script src="zone.min.js"></script>
出现这个问题的三种可能
1) 我们将此脚本包含在 index.html 页
<script>window.module = 'aot';</script>
所以我们必须在每个组件中包含模块字段以及选择器和模板
@Component({
moduleId: module.id,
selector: 'myapp',
templateUrl: '../../master/html/test.html'
})
2)这个脚本应该在html页的底部
<script src="dist/build.js"></script>
3)最后但重要的是,提前编译没有延迟加载
这解决了我的问题,使用 AOT 的应用程序 运行 但内部遇到了一些问题,例如堆栈的 Zoneware 错误 undefined.Resolving。