我正在关注本教程:http://campus.codeschool.com/courses/shaping-up-with-angular-js/level/4/section/1/video/1
我做的唯一不同的是在我的文件结构中添加一个文件夹。 即使我删除它并将“product-title.html”与我的index.html 一起放入根目录中,它也不起作用。
<h3 ng-include="'includes/product-title.html'"></h3>
这看起来很简单,我做错了什么吗?
product-title.html中的代码是:
{{product.name | uppercase}}
<em class="pull-right">{{product.price | currency}}</em>
我正在使用以下依赖项:
"dependencies": {
"angular": "^1.4.7",
"bootstrap": "^3.3.5"
}
最佳答案
基于您提到的错误
XMLHttpRequest cannot load file:///C:/includes/product-title.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
你不能点击html文件并直接运行它,必须在本地服务器(例如Apache)上运行它
关于javascript - 即使使用单引号,ng-include 也不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33678866/