AngularJS请求数据提示resource from url not allowed by $sceDelegate policy

AngularJS iframe跨域打开内容时报错

解决方案 使用  $sceDelegateProvider  配置跨域请求域名

config.js

app.config(function($sceDelegateProvider) {
   $sceDelegateProvider.resourceUrlWhitelist([
       // Allow same origin resource loads.
       'self',
       // Allow loading from our assets domain.  Notice the difference between * and **.
       'http://www.baidu.com/**']);
});

xx.js

$sce.trustAsResourceUrl(pdf.Url)

html:

<iframe style="width:100%; height:1000px;" frameborder="0" ng-src="{{pdf.Url}}"></iframe>

 

posted @ 2019-08-07 14:14  jasonlai2016  阅读(486)  评论(0编辑  收藏  举报