【发布时间】:2017-10-27 15:10:41
【问题描述】:
我有一个 index.html 文件和另一个 topBar.html 文件,我想将该文件包含在我的 index.html 中。
我的目录结构如下:
mainfolder/
scripts/
views/
topBar.html
index.html
这是我尝试过的代码
<div ng-controller="mainCtrl">
<div ng-include="'views/topBar.html'"></div>
</div>
但没有显示任何内容,并且在控制台中出现错误
angular.js:12701 加载失败 文件:'路径'交叉原点 请求仅支持协议方案:http、data、chrome、 chrome 扩展,https。
【问题讨论】:
-
错误信息说明了一切。不要尝试从文件系统运行您的 Angular web 应用程序。通过从 web 服务器通过 http 提供文件来运行它。
标签: angularjs