无法使用angularJS将网址加载到iframe中 [英] Can't load URL into iframe with angularJS

查看:1851
本文介绍了无法使用angularJS将网址加载到iframe中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用AngularJS,我试图加载myLinkURL地址到另一个html的iframe。
data.No是我从另一个地方拉的工作正常(获取我需要的URL的Id)

Using AngularJS, Im trying to load the "myLink" URL address to iframe in another html. data.No is the id that i pull from another place and works fine (get the Id that i need for the url)

在控制器 - TransactionsCtrl:

in the controller - "TransactionsCtrl":

$scope.myLink = "http://"the real url"+ data.No +"&file="+ data.No +"&contract_id="+ data.No;
console.log($scope.myLink);

<div ng-controller= "TransactionsCtrl">
    <iframe ng-src="{{myLink}}"></iframe>
</div>

所有我得到的是:

Error: [$interpolate:interr] Can't interpolate: {{myLink}}
Error: [$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy.  URL

推荐答案

在控制器中,您应该使用:

In the controller you should use:

   $scope.myLink =  $sce.trustAsResourceUrl(myUrl)

这篇关于无法使用angularJS将网址加载到iframe中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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