AngularJS访问被拒绝在IE11装载部分时, [英] AngularJS Access denied when loading partial in IE11

查看:296
本文介绍了AngularJS访问被拒绝在IE11装载部分时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我试图制定一个 AngularJS 应用程序,被托管的离线HTML作为器Resco MobileCRM 软件。该软件通过自己的JavaScript库提供的CRM数据脱机访问,这是工作的罚款。我也能得到一个非常简单的应用angularjs工作,在检索和显示数据的条款。

I am attempting to develop an AngularJS app that is to be hosted as 'offline html' as part of the Resco MobileCRM software. This software provides offline access to CRM data via its own javascript libraries and this is working fine. I am also able to get a very simple angularjs application working, in terms of retrieving and displaying the data.

在AngularJS应用程序上传到使用器Resco接口CRM,然后经由器Resco软件下载到每个客户端机器。实际文件最终在用户的 AppData的文件夹中的每个客户机上。

The AngularJS application is uploaded to the CRM using the Resco interface and then is download to each client machine via the resco software. The actual files end up in the users AppData folder on each client machine.

问题

当我介绍路由到角的应用程序,或者使用 ngRoute UI路由器,我收到< STRONG>访问被拒绝的错误。器Resco软件使用底层浏览器,这在我的情况下的 IE11 。我有误差缩小时,角正试图加载谐音的路线。

When I introduced routing to the angular app, either using ngRoute or ui-router, I am getting Access Denied errors. The resco software uses the underlying browser, which in my case is IE11. I have narrowed down the error to when angular is attempting to load the partials for the routes.

违规的code是低于(angular.js v1.3.15行9805)

The offending code is below (angular.js v1.3.15 line 9805)

  xhr.open(method, url, true);

从我的研究,它看起来像IE认为我试图一个CORS请求,但我只是尝试加载从磁盘上的文件。
各个岗位建议我加入的网站受信任的站点,但我不实际访问其他网站。我的不能作为整个目的是让器Resco MobileCRM 应用程序中的这个角度应用程序离线访问Web服务器上的主机此

From my research, it seems like IE believes I am attempting a CORS request, however I am just attempting to load a file from disk. Various posts suggest I add the site to 'Trusted Sites', however I am not actually accessing another site. I also cannot host this on a web server as the whole purpose is to have this angular application accessible offline within the Resco MobileCRM application

我也得到同样的错误,如果我浏览到 AppData的文件夹,并直接从那里(即无法运行该angularjs应用在器Resco应用程序)。

I also get the same error if I navigate to the AppData folder and run the angularjs application directly from there (i.e. not in the resco application).

其他的职位,建议我需要更换 XMLHtt prequest 通过角与 XDomainRequest 创建,但我不愿意改变角度库,尤其是如果我不明白为什么。

Other posts have suggested that I need to replace the XMLHttpRequest created by Angular with XDomainRequest but I am reluctant to change the angular library, especially if I don't understand why.

请问AP preciate它,如果任何人都可以解释为什么发生这种情况以及如何解决它的一些情况。

Would appreciate it if anyone could shed some light on why this is happening and how to fix it.

推荐答案

我已经证实,这是不可能在任何浏览器。你不能让XHR请求文件从本地磁盘提供服务。

I have confirmed that this is not possible on any of the browsers. You cannot make xhr requests to files served locally from disk.

我得到了解决此问题通过在脚本标签加载我的'谐音'和参照指令这些脚本标签的ID指令。

I got around this problem for directives by loading my 'partials' in to script tags and referring to the id of these script tags in the directives.

我没有尝试与ui.router或ngRoute,而是选择了重新设计中一些较小的应用我的应用程序,因为他们并不需要共享任何上下文

I did not try that with ui.router or ngRoute and instead opted to redesign my application in to a number of smaller application as they did not need to share any context

这篇关于AngularJS访问被拒绝在IE11装载部分时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆