【发布时间】:2015-06-25 02:22:06
【问题描述】:
假设我有一个名为“test”的控制器:
$scope.testValue = "Hello World!";
index.html:
<div ng-controller="test">
<iframe iframe-directive src="template.html"></iframe>
</div>
模板.html:
{{testValue}}
iframe 指令如何编译它并输出“Hello World”而不是“{{testValue}}”?
【问题讨论】:
-
恐怕你不能在不同页面之间共享角度上下文,即你的
index.html和template.html。 -
你可以试试
templateUrlinngRoute: docs.angularjs.org/tutorial/step_07 -
我一直在寻找答案,发现 $compile 可以做到。类似 $compile(elem.contents())(scope);但我就是不能让它工作。真的不可能吗?
-
神圣的。 . .让它工作。我只是没有使用最新版本的 angularjs
-
太棒了。你能分享一些 JSFiddle 吗?
标签: angularjs iframe compilation