Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular2-使用组件模板URL中的绝对路径编译为AOT_Angular_Angular2 Aot - Fatal编程技术网

Angular2-使用组件模板URL中的绝对路径编译为AOT

Angular2-使用组件模板URL中的绝对路径编译为AOT,angular,angular2-aot,Angular,Angular2 Aot,我使用Angular2,并使用AOT预编译代码 当我在组件的templateUrl中使用相对路径时,我能够编译代码 但在组件的templateUrl中使用绝对路径时编译失败 编译命令:“node\u modules/.bin/ngc”-p tsconfig aot.json 我在使用绝对模板URL时遇到以下错误: 错误:编译失败。未找到资源文件:{绝对htmlUrl 路径} 在ModuleResolutionHostAdapter.readResource(C:\Dipendra\stash w

我使用Angular2,并使用AOT预编译代码

当我在组件的templateUrl中使用相对路径时,我能够编译代码

但在组件的templateUrl中使用绝对路径时编译失败

编译命令:
“node\u modules/.bin/ngc”-p tsconfig aot.json

我在使用绝对模板URL时遇到以下错误:

错误:编译失败。未找到资源文件:{绝对htmlUrl 路径} 在ModuleResolutionHostAdapter.readResource(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\angular\compiler cli\src\compiler\u host.js:291:19) 在CompilerHost.loadResource(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler cli\src\compiler\u host.js:230:85) 在Object.get(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:26374:111) 在DirectiveNormalizer._fetch(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:13753:47) 在DirectiveNormalizer.normalizeTemplateAsync(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:13799:25) 在DirectiveNormalizer.normalizeTemplate(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:13771:48) 在CompileMetadataResolver.\u loadDirectiveMetadata(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:18074:79) 在C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:18250:58 at Array.forEach(本机) 在CompileMetadataResolver.loadNgModuleDirectiveAndPipeMetadata(C:\Dipendra\stash workspace\angular2Aot\WebContent\node\u modules\@angular\compiler\bundles\compiler.umd.js:18249:45) 编译失败


Angular AOT编译器要求模板文件与组件位于同一文件夹中,即使JIT编译器不需要这样做

对于设计师来说,这是一个极其糟糕的决定。答案是重新设计整个应用程序,使模板文件与组件位于同一文件夹中

有几种假设的解决方法,但我不清楚它们是否真的有效。如果我成功了,我会更新这个帖子