使用angularjs构建iframe url

使用angularjs构建iframe url,angularjs,iframe,src,Angularjs,Iframe,Src,我从一个我希望是动态的url获得一个iframe图像。例如,我想为我正在预览的每个应用程序传递一个不同的url 我曾尝试使用ng src生成我的url,但似乎失败了 html: 获取此错误: angular.js:11706错误:[$interpolate:noconcat]插值时出错 有什么想法吗?好吧,你不能像那样连接一个字符串。其次,您需要使用$sce并告诉您的应用程序它是一个受信任的url资源。参见小提琴: <iframe ng-src="http://localhost:3000

我从一个我希望是动态的url获得一个iframe图像。例如,我想为我正在预览的每个应用程序传递一个不同的url

我曾尝试使用ng src生成我的url,但似乎失败了

html:

获取此错误: angular.js:11706错误:[$interpolate:noconcat]插值时出错


有什么想法吗?

好吧,你不能像那样连接一个字符串。其次,您需要使用
$sce
并告诉您的应用程序它是一个受信任的url资源。参见小提琴:

<iframe ng-src="http://localhost:3000/v4/{{applicationNumberText}}/{{documentIdentifier}}"></iframe>
$scope.applicationNumberText = '09123456';
$scope.documentIdentifier = 'E1DUJW9JPP1GUI3';
app.controller('TestController', function($scope,$sce) {
  $scope.applicationNumberText = '09123456';
  $scope.documentIdentifier = 'E1DUJW9JPP1GUI3';
  $scope.iFrameUrl = $sce.trustAsResourceUrl("http://localhost:3000/v4/" + $scope.applicationNumberText + "/" + $scope.documentIdentifier);
});