angularjs IE 11 $ sceDelegate策略不允许阻止从url加载资源

时间:2014-09-16 19:05:46

标签: angularjs internet-explorer-11

基于我的angularjs(1.2.14)的应用程序在IE10中加载正常。但是在IE11中,模板URL被阻止,应用程序无法正确呈现。以下是我在控制台中看到的错误。我看到这是一个已知问题,但已修复(http://blog.jongallant.com/2013/09/scedelegate-plicy-insecurl.html#.VBiGz_ldWAg

Error: [$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy.  URL: resources/partials/overview.start.html
http://errors.angularjs.org/1.2.14/$sce/insecurl?p0=resources%2Fpartials%2Foverview.start.html
at getTrusted (https://myserver.com/resources/lib/angular/1.2.14/angular.js:12849:11)
at Anonymous function (https://myserver.com/resources/lib/angular/1.2.14/angular.js:13535:9)
at Anonymous function (https://myserver.com/resources/lib/angular/1.2.14/angular-route.js:528:17)
at wrappedCallback (https://myserver.com/resources/lib/angular/1.2.14/angular.js:11046:15)
at wrappedCallback (https://myserver.com/resources/lib/angular/1.2.14/angular.js:11046:15)
at Anonymous function (https://myserver.com/resources/lib/angular/1.2.14/angular.js:11132:11)
at $eval (https://myserver.com/resources/lib/angular/1.2.14/angular.js:12075:9)
at $digest (https://myserver.com/resources/lib/angular/1.2.14/angular.js:11903:15)
at $apply (https://myserver.com/resources/lib/angular/1.2.14/angular.js:12179:13)
at Anonymous function (https://myserver.com/resources/lib/angular/1.2.14/angular.js:1341:9) 

Error: [$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy.  URL: template/accordion/accordion-group.html
http://errors.angularjs.org/1.2.14/$sce/insecurl?p0=template%2Faccordion%2Faccordion-group.html
at getTrusted (https://myserver.com/resources/lib/angular/1.2.14/angular.js:12849:11)
at Anonymous function (https://myserver.com/resources/lib/angular/1.2.14/angular.js:13535:9)
at compileTemplateUrl (https://myserver.com/resources/lib/angular/1.2.14/angular.js:6463:7)
at applyDirectivesToNode (https://myserver.com/resources/lib/angular/1.2.14/angular.js:6066:11)
at compileNodes (https://myserver.com/resources/lib/angular/1.2.14/angular.js:5668:9)
at compile (https://myserver.com/resources/lib/angular/1.2.14/angular.js:5601:7)
at applyDirectivesToNode (https://myserver.com/resources/lib/angular/1.2.14/angular.js:5995:13)
at compileNodes (https://myserver.com/resources/lib/angular/1.2.14/angular.js:5668:9)
at compile (https://myserver.com/resources/lib/angular/1.2.14/angular.js:5601:7)
at applyDirectivesToNode (https://myserver.com/resources/lib/angular/1.2.14/angular.js:6009:13)<div class="snap-drawer snap-drawer-left ng-scope" 

1 个答案:

答案 0 :(得分:0)

您的错误报告包含一个解决方案。 链接到AngularJS KB:https://docs.angularjs.org/error/$sce/insecurl?p0=template%2Faccordion%2Faccordion-group.html

现在引用该页面:

  

通常,如果您尝试加载Angular,则会发生这种情况   来自不受信任来源的模板。这也可能是一个习惯   指令因类似原因抛出此错误。

     

Angular仅从受信任的URL加载模板(通过调用   模板URL上的$ sce.getTrustedResourceUrl。

     

默认情况下,只有属于同一来源的网址才受信任。   这些是具有相同域,协议和端口的URL   申请文件。

     

指定templateUrl的ngInclude指令和指令   需要受信任的资源URL。

     

要从其他域和/或协议加载模板,请进行调整   白名单/黑名单或通过调用来包装URL   $ sce.trustAsResourceUrl。

     

注意:浏览器的同源策略和跨源资源   共享(CORS)政策适用可能进一步限制是否   模板已成功加载。 (例如,两个跨域请求都没有   不适用于所有浏览器,也不适用于某些浏览器上的file://请求