我尝试$localstorage
在本地存储文件路径并使用iframe
预览文件,但我收到错误。
$scope.getResume = function() {
var resumeJson = {
"json":{
"request":{
"candidateid":$rootScope.globals.currentUser.userId,
"type":2
}
}
};
var getresume = "http://MyServerURL?request=" + JSON.stringify(resumeJson);
$scope.resume = $localStorage.$default({x: getresume});
}
HTML:
<iframe id="resume" src="{{resume.x}}" style="margin-top: 2em; height: 100%; width: 100%;"></iframe>
但我收到错误并在框架内显示错误消息:
不能获得/%7B%22json%22:%7B%22request%22:%7B%22candidateid%22:44,%22type%22:2%7D%7D%7D
当我尝试检查页面时,我发现iframe src = "{"json":{"request":{"candidateid":44,"type":2}}}"
而不是我的网址。
答案 0 :(得分:0)
看,我为你写了一个Plunker。它是动态设置iFrame src的100%工作解决方案。
https://plnkr.co/edit/tpl:CR2TtS1zz9wFGgsl5z2c?p=preview
也许您应该将src
更改为ng-src
。
<iFrame ng-src="{{mc.resume}}"></iFrame>