【发布时间】:2016-07-05 10:19:07
【问题描述】:
我遇到了 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 像循环一样被连续触发
我不明白这里发生了什么
任何帮助将不胜感激。
【问题讨论】:
-
在您的
$scope.getIframeSrc函数中为您的 filepath 执行 console.log 并检查路径 -
我得到了正确的路径@MohanGopi
-
console.log( $scope.getIframeSrc());试试这个并检查
标签: javascript angularjs iframe