我正面临iframe src的一个问题,我正在调用一个函数来绑定我的返回值
这是代码
<div class="collapse" class="col-xs-6" ng-if="setFrame">
<iframe width="100%" height="650px" ng-src="{{getIframeSrc()}}" ></iframe>
控制器代码就像
angular.module('hrPortalApp')
.controller('topicsCtrl', function($scope, $state, $stateParams, getCandidateInterviewListService, searchBoxService, iterateArray)
angular.forEach($stateParams.candidateDetails, function(value, key) {
if (value.name == $stateParams.name) {
$scope.file = value.filepath;
}
$scope.setFrame=true;
});
$scope.getIframeSrc = function() {
var filepath='http://localhost:4000/' + $scope.file;
return filepath
};
但是这里函数getIframeSrc像循环一样被连续触发
我不明白这里发生了什么
任何帮助都将不胜感激。
答案 0 :(得分:1)
它在循环中调用,因为引擎会检查整个时间的更改。 每次你的函数运行时都会发生一些变化,所以它变成了一个&#34;循环&#34;。
HTML
<div class="collapse" class="col-xs-6" ng-if="setFrame">
<iframe width="100%" height="650px" ng-src="{{iframeSrc}}" ></iframe>
JS
$scope.iframeSrc = 'http://localhost:4000/' + $scope.file;