【发布时间】:2015-08-29 09:01:45
【问题描述】:
我有一个表格来修改我的范围。然后使用此范围更新我网站中的另一部分。 那部分,我现在想放入一个单独的(模板)文件并动态加载到 iframe 中。
如果我向 Iframe 提供静态 HTML,它就可以工作,但我无法通过加载另一个文件作为模板来运行它。
这是我当前的代码:
cvFormApp.directive('cvframe', function($compile, $http, appConfig) {
$http({
url: appConfig.baseUrl + 'res/templates/classic.html',
method: 'GET'
}).then(function(response) {
tpl = response.data;
});
return function($scope, $element, tpl) {
var $body = angular.element($element[0].contentDocument.body),
template = $compile('<h1>The date in the iframe is {{date}}</h1>')($scope);
$body.append(template);
};
});
如何将引用的 classic.html 插入 iframe 并绑定到我的其余代码?
【问题讨论】:
标签: angularjs iframe asynchronous angularjs-directive angular-http