包括不在铬浏览器中工作 [英] ng include not working in chrome browser
问题描述
我是AngularJs的新手。我试图在我的index.html文件中使用ng-include指令来包含标题模板。在我的本地我运行它在独立模式,而不是在任何Web服务器上。索引页正在Chrome上的Firefox上完美加载头文件。我收到一个错误,指出只有HTTP支持跨源请求。
来自错误堆栈的更多日志粘贴在下面:
资源解释为脚本,但以MIME类型text / html:file:///Users/pradeep/Angular_demo/header.html传输。 index.html:305
XMLHttpRequest无法加载
文件:///Users/pradeep/Angular_demo/header.html。
只有HTTP支持跨源请求。 angular.js:8109
(匿名函数)angular.js:8109
sendReq
请帮我解决Chrome上的这个问题,以便我可以运行这个作为独立应用程序。
问候,
Pradeep
使用与app目录相关的路径。例如: header.html
if Angular_demo
是项目的根目录。
不尝试通过文件
协议访问资源
I am new to AngularJs. I am trying to use ng-include directive in my index.html file to include header template. IN my local I am running it in standalone mode and not on any web server. The index page is loading the header file perfectly on firefox wheras on Chrome. I get an error stating "Cross origin requests are only supported for HTTP."
Some more logs from the error stack is pasted below:
Resource interpreted as Script but transferred with MIME type text/html: "file:///Users/pradeep/Angular_demo/header.html". index.html:305 XMLHttpRequest cannot load file:///Users/pradeep/Angular_demo/header.html.
Cross origin requests are only supported for HTTP. angular.js:8109 (anonymous function) angular.js:8109 sendReq
Please help me resolving this issue on Chrome so that I can run this as standalone application.
Regards, Pradeep
use a path that is relative to the app directory. ex: header.html
if Angular_demo
is the project's root directory.
dont try to access resources through the file
protocol
这篇关于包括不在铬浏览器中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!