$ sce.trustAsResourceUrl不工作 [英] $sce.trustAsResourceUrl is not working
问题描述
我在我的项目中的iframe的工作只是试图通过iframe中打开我的应用程序里面的网址,但在我结束它不工作,请看看,并提供您宝贵的suggestion.I将非常感谢全给你。
下面是我的控制器code: -
app.controller('IframeCtrl',函数($ HTTP,$范围,$ ionicPopup,$状态\r
$ ionicLoading,本地存储,$ SCE){\r
\r
$ scope.customUrl = $ sce.trustAsResourceUrl('http://www.magentomobileshop.com/demo/payu/index/payu?orderid=\r
+ LocalStorage.getData(订单ID));\r
\r
window.checkIframeUrl =功能(curentUrl){\r
警报(curentUrl);\r
};\r
\r
\r
});
\r
我iframe.hml: -
<离子查看查看标题=PayU钱> <离子导航栏\r
类=扎阳对齐标题=中心> < /离子导航栏> < IFRAME\r
SRC ={{customUrl}}SRC =http://www.google.com\r
的onLoad =checkIframeUrl(SRC); SCROLLING =无FRAMEBORDER =0\r
高度=600px的WIDTH =100%>< / IFRAME> <离子含量> < /离子含量> < /离子视图>
\r
这是我现在尝试为: -
我的电脑板: -
函数($ HTTP,$范围,$ SCE){\r
\r
\r
VAR URL =http://www.magentomobileshop.com/demo/payu/index/payu?orderid=100000030\r
\r
$ http.get($ sce.trustAsResourceUrl(URL))。成功(功能(数据){\r
$ scope.myData =数据;\r
\r
});\r
\r
}
\r
我的新的HTML: -
< DIV>< IFRAME\r
NG-SRC = {{myData的}} FRAMEBORDER =0\r
高度=600px的WIDTH =100%>< / IFRAME> < / DIV>\r
< / DIV>
\r
好吧,我想这可能是payU是一个保护的URL所以这可能不会得到在iFrame中打开,但有什么办法,我可以跟踪window.open()的URL的问题,这样我就可以关闭网页视图当我将在该跟踪网址。
感谢
嗯等待。我没有注意到你正在膨胀的值作为查询参数。
我不认为它可能以任何方式工作。
你只是填充一个地址,白名单的链接,你没有得到的数据。
您也许可以使用
$ HTTP({
网址:$ sce.trustAsResourceUrl(yourURL)
方法:GET
})。然后(
功能(数据){
$ scope.myData =数据;
},
功能(错误){
//管理错误
}
);
I am working with iframe in my project just tried to open url inside my app through iframe , but its not working at my end , please have a look and provide your valuable suggestion.I will be very thank full to you .
Here is my controller code :-
app.controller('IframeCtrl', function($http, $scope, $ionicPopup, $state,
$ionicLoading, LocalStorage, $sce) {
$scope.customUrl = $sce.trustAsResourceUrl('http://www.magentomobileshop.com/demo/payu/index/payu?orderid='
+ LocalStorage.getData("orderid"));
window.checkIframeUrl = function(curentUrl) {
alert(curentUrl);
};
});
My iframe.hml :-
<ion-view view-title="PayU Money"> <ion-nav-bar
class="bar-positive" align-title="center"> </ion-nav-bar> <iframe
src="{{customUrl}}" src="http://www.google.com"
onLoad="checkIframeUrl(src);" scrolling="none" frameborder="0"
height="600px" width="100%"></iframe> <ion-content> </ion-content> </ion-view>
I even try this link :- http://jsfiddle.net/W4WyL/4/
here is what i try now as :-
My conroller :-
function($http, $scope, $sce) {
var url="http://www.magentomobileshop.com/demo/payu/index/payu?orderid=100000030"
$http.get($sce.trustAsResourceUrl(url)).success(function(data) {
$scope.myData = data;
});
}
My new Html :-
<div><iframe
ng-src={{myData}} frameborder="0"
height="600px" width="100%"></iframe> </div>
</div>
Okay, i think this might be the issue that payU is a secured Url so this might not be getting open on iFrame but is there any way i can track url in window.open(), so that i can close the webview when i will be on that tracked Url.
Thanks
Ah wait. I didn't notice you are inflating that value as a query param. I don't think it could work in any way. You are just filling an address, and whitelisting a link, you are not getting the data.
You probably could use
$http({
url : $sce.trustAsResourceUrl( yourURL ),
method : "GET"
}).then(
function(data){
$scope.myData = data;
},
function(error){
// manage error
}
);
这篇关于$ sce.trustAsResourceUrl不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!