以 src 作为动态属性的 iframe

问题描述 投票:0回答:1

下午好。我有一个 Angular JS 应用程序,它可以正确生成 SSRS 报告。但它是硬编码的。我想从配置中提高 url。

为此,我在视图中替换了它:

<div>
       <iframe ng-src="{{vm.report}}" height="600" width="100%"></iframe>
</div>

其中:vm.report 是:

function BalancesController(.......) {
    var vm = this;
    
     function initialize() {
          vm.report = window.ReportLoadBaskets + "?rs:Embed=true";
     }
}

但我收到此错误:

错误:$sce:insecurl 阻止处理来自不受信任来源的资源 $sceDelegate 策略不允许从 url 阻止加载资源。网址:http://pcxxx/Reports/report/Gener/Events?rs:Embed=true

我该如何解决这个问题?

谢谢!!

angularjs iframe
1个回答
0
投票

请告诉我这是否适合您..

<div>
    <iframe ng-src="{{vm.report}}" height="600" width="100%"></iframe>
</div>


function BalancesController($sce) {
    var vm = this;

    function initialize() {
        var src = window.ReportLoadBaskets + "?rs:Embed=true";
        vm.report = $sce.trustAsResourceUrl(src);                    

    }
}
© www.soinside.com 2019 - 2024. All rights reserved.