Angularjs-检索给定链接的页面的html

Angularjs - Retrieve html of page given a link

本文关键字:html 链接 检索 Angularjs-      更新时间:2023-09-26


如何从angular指令获取网页的html代码?在我的例子中,我有一个html代码:

<div class="modal-body" data-ng-bind-html="myHTML">
</div>

我想在div中放置另一个页面的内容!在我的指令中,我做了一些类似的事情:

$rootScope.myHTML = link;

链接应该包含页面的整个html!如果myHtml="http://www.google.com",我如何检索‘链接’的内容?

听起来你真的只想在视图中应用外部网站,然后你应该在iframe中链接它。

<iframe src="http://www.google.com"></iframe>

您可以直接将指令的所有html插入到html中,仅限自身。在您的父html中,您可以像一样插入directive.html

<directive></directive>