Cross origin requests are only supported for HTTP

假装没事ソ 提交于 2019-11-28 21:38:44

You can add templates such as p1.html and p2.html in your index.html by putting them inside script tags, as mentioned in the docs.

<script type="text/ng-template" id="p1.html">
  This is the content of the template
</script>

Then angular will no longer need to make AJAX requests to fetch them.

Do note that these script elements must appear after ng-app.

JulienBrks

I've got the same trouble in Chrome, if you are using Chrome, you can disable same origin policy in Chrome. Starting the Chrome runs:

$ google-chrome --disable-web-security

Here's more detail.

Route provider uses http protocol that's why if you will run this code directly from folder, you will get cross origin issue.

Keep your folder on a server like localhost/route and run it.

Provide reference path like templateUrl: '/p1.html'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!