gpt4 book ai didi

javascript - Angular : Write HTML Output to textfile

转载 作者:行者123 更新时间:2023-11-28 03:28:01 25 4
gpt4 key购买 nike

我正在使用 PhoneGap 开发 AngularJS 1.5 项目。现在我想将 HTML 输出写入文本文件。

我试图使用 innerHTML 函数,但这返回了错误的输出,例如这个返回:

<html>
<body>Hi {{ Name }}</body>
</html>

我真正想保存的是:

<html>
<body>Hi Developer</body>
</html>

有人有解决方案吗?谢谢!

最佳答案

这比乍看起来要复杂一些。 Angular 没有某种你可以轻松获取的输出缓冲。您最好的选择是使用浏览器保存呈现的标记。在 Firefox 中,您可以使用 View Source » View Generated Source。在 Chrome 中,您可以在工具菜单下找到类似的选项。

或者如果您想走代码之路,这里是来自 Angular devs, Misko Hevery 之一的回复:

We have not done this, but if you feel up to it here is what you can try

  • get node.js running
  • install of the many DOM implementations for node
  • Get your angular page running inside the node.js.
  • Get a hold of the $browser service and call notifyWhenNoOutstandingRequests() this will tell you when the page finished rendering
  • Do document.html() to get rendered HTML

[...]

关于javascript - Angular : Write HTML Output to textfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19948327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com