AngularJS错误:只支持协议方案的跨源请求:http、data、chrom-扩展名、https。
我有一个非常简单的角js应用程序的三个文件。
index.htmlhtml>
{{product.name}} {{product.price | currency}}
产品-彩色.html
Hello Brother
app.js(function() {
var app = angular.module('gemStore', []);
app.controller('StoreController', function($http){
this.products = gem;
}
);
app.directive('productColor', function() {
return {
restrict: 'E', //Element Directive
templateUrl: 'product-color.html'
};
}
);
var gem = [
{
name: "Shirt",
price: 23.11,
color: "Blue"
},
{
name: "Jeans",
price: 5.09,
color: "Red"
}
];})();
当我使用名为ProductColor的自定义指令输入了Product-chro.html的包含时,我就开始得到这个错误:XMLHttpRequest cannot load file:///C:/product-color.html. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.angular.js:11594 Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/product-color.html'.
可能出什么问题了?这是产品的路径问题吗?
我的三个文件都在同一个根文件夹中。C:/user/project/