javascript - 即使使用单引号,ng-include 也不起作用

标签 javascript angularjs include frontend

我正在关注本教程: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"
  }

file structure

最佳答案

基于您提到的错误

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/

相关文章:

php - 检查是否存在包含(或要求)

javascript - 如何根据输入值使用javascript在mysql中插入数据

javascript - 具有可调整大小的列的表,应该动态添加/删除列并使用列中的可排序值

javascript - 如何以 Angular 观看字符串更改 - 添加退格键?

javascript - 使用模式表单时,AngularJS 数据表未更新

php - 最佳实践 : include( or &lt;script src="

javascript - AngularJS 单选按钮在加载时未检查

javascript - Node 调度触发问题

angularjs - 如何检查 Protractor 是否显示多个元素?

PHP 包含同一库的不同版本