将AngularJS 1.4.7注入IE交叉延伸器扩展

Irt*_*.QC 11 javascript jquery crossrider angularjs internet-explorer-11

我正在使用Crossrider框架为浏览器开发扩展.我正在使用这条线

appAPI.resources.includeJS('js/angular.min.js');
Run Code Online (Sandbox Code Playgroud)

将angular.js注入扩展名.这在Chrome上工作正常,但在IE 11上我收到错误

---- JS Exception from: IE test staging ----
Error: Object expected
Source: Microsoft JScript runtime error
Location: resources
Line: 131
Run Code Online (Sandbox Code Playgroud)

我环顾四周,发现了一些答案,表明jQuery可能会丢失,或者代码本身可能有一个尾随逗号.但是,我正在使用

var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('body')[0].appendChild(jq);
Run Code Online (Sandbox Code Playgroud)

将jquery注入到文档中,这应该不是问题.至于JS中有一个尾随逗号的可能性,我从AngularJS的缩小版本变为非透明版本,但仍然得到了同样的错误,这让我觉得错误中的行号没有意义.如果这是关心,或忘记,无论是什么情况.有人可以告诉我发生了什么以及如何解决它?

PS.我的环境是在Ubuntu 14.04 LTS x64位计算机上的VMWare Workstation 12上的Windows 7 Ultimate 32位

Shl*_*omo 1

我认为你这里有一个混合范围的问题。appAPI.resources.includeJS在扩展页面范围中运行,您添加的jq元素在 HTML 页面范围中运行。如果要将 AngularJS 添加到 HTML 页面范围,请使用appAPI.resources.addInlineJS,如下所示:

var jq = document.createElement('script');
jq.src = "https://http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('body')[0].appendChild(jq);
appAPI.resources.addInlineJS('js/angular.min.js');
Run Code Online (Sandbox Code Playgroud)

[披露:我是 Crossrider 员工]