我需要使用< \ object>标签或< \ iframe>在我的部分html中,并使用ng-include在另一个html页面中使用该html。这是我的尝试,
<div class="container">
<!-- This part is not showing anything in the page -->
<object ng-attr-data='"templates/widget_1.html"' type="text/html"></object>
<!-- This part is showing page in view -->
<div ng-include src='"templates/widget_2.html"'></div>
</div>
OR
如果我想使用&lt; \ iframe&gt;在这个页面中我该如何使用它?
答案 0 :(得分:0)
要实现这一点,您需要编写一个指令并自己加载模板
app.directive("object", function ($templateCache, $http, $compile)
{
return {
restrict:"E",
link: function ($scope, $element)
{
//load the external partial with http and cache into the $templateCache
$http.get($element.attr("ng-attr-data"), {cache: $templateCache}).then(function (response)
{
//Fill the loaded html into the element
$element.html(response.data);
//compile the scope on it, to enable bindings.
$compile($element.contents())($scope);
});
}
}
});