我正在做一个项目,我正在使用AngularJS的特征指令。 我的指令代码如下:
app.directive('programListing', function() { return { restrict:'E', scope: { listing:'=' }, templateUrl:'js/directives/programListing.html' }; });每当我尝试在Chrome上加载index.html ,它都会给出: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. 错误。 我尝试通过Apache服务器2加载index.html但它给出: Not allowed to load local resource错误,因为我的index.html文件包含来自本地驱动器的一些图像。 那么,如何配置Apache 2以便它从我的计算机的本地驱动器访问文件,这样我也可以离线完成我的工作。 提前致谢!! :-)
I'm doing a project where I'm using directives characteristic of AngularJS. Code of my directive looks like this:
app.directive('programListing', function() { return { restrict:'E', scope: { listing:'=' }, templateUrl:'js/directives/programListing.html' }; });Whenever I try to load index.html on Chrome it gives: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. error. I tried loading index.html through Apache server 2 but it gives: Not allowed to load local resource error, due to the fact that my index.html file contains some images from local drives. So, how to configure Apache 2 so that it access files from local drives of my computer, so that I can do my work offline too. Thanks in advance!! :-)
最满意答案
我得到了答案!! 通过稍微更改本地文件上的图像地址来解决问题。 首先,我将图像文件放在Apache文件的htdocs文件夹中,然后我用它作为我的文件地址: http://localhost/image-name.jpg这解决了这个问题。
I got an answer!! The problem get solved by slightly changing the image address on the local file. Firstly, I placed the image file inside htdocs folder of Apache files, then I used this as my address to the file: http://localhost/image-name.jpg This solved the problem.
更多推荐
发布评论