【发布时间】:2017-01-22 02:05:19
【问题描述】:
据我了解,Angular 2 组件中的所有 templateUrl 和 styleUrl 路径都是从 index.html 解析的。
但是,我想将我的开发和运行文件夹分开,因此将我的 .html 文件与我的 .ts 模块、路由器、组件等放在 dev 文件夹中。并已将 .js 编译到应从其中启动 Angular 的兄弟 app 文件夹。
目录结构如下:
top directory
|
*-- app (compiled .js here, index.html here)
|
*-- dev (.ts here, .component.html files here)
问题是我无法访问 dev 文件夹中的 .component.html 文件,而 index.html 位于 app 文件夹中。我已经尝试从 app 文件夹进行绝对路径向上并进入同级文件夹,但这似乎不起作用。
@Component({
templateUrl: 'app/../dev/path/path.component.html'
...
)}
上述情况的错误是 404 not found on the .html file from localhost:3000/dev/path/path.component.html
将 .component.html 结构和文件复制到 /app 可以,但很麻烦。
是否可以将 templateUrl (styleUrl) 位置上游设置为 index.html 所在的父级或兄弟级?
【问题讨论】:
标签: angular