Angular JS:可以将$ scope传递给iframe并使用传递的范围编译iframe的内容吗?

时间:2015-06-25 02:22:07

标签: angularjs iframe compilation

说我有控制器名为" test"用:

$scope.testValue = "Hello World!";

的index.html:

<div ng-controller="test">
    <iframe iframe-directive src="template.html"></iframe>
</div>

template.html:

{{testValue}}

iframe指令如何编译并输出&#34; Hello World&#34;而不是&#34; {{testValue}}&#34;?

1 个答案:

答案 0 :(得分:0)

只需将其置于iframe指令中即可使用

link: function(scope,elem,attrs) { $compile(elem.contents())(scope); }